Skip to content

Commit

Permalink
Merge pull request #411 from shorepine/tdeckfixes
Browse files Browse the repository at this point in the history
fixes so the tdeck boots again
  • Loading branch information
bwhitman authored Oct 29, 2024
2 parents 68bbdb9 + eab3cf5 commit 1e4550d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions tulip/esp32s3/boards/TDECK/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

#define USB_SERIAL_JTAG_PACKET_SZ_BYTES 64

#define MICROPY_ESP32_USE_BOOTLOADER_RTC (0)
#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs,args) void
//#define MICROPY_ESP32_USE_BOOTLOADER_RTC (0)
//#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs,args) void
6 changes: 4 additions & 2 deletions tulip/esp32s3/gt911_touchscreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ void run_gt911(void *param) {
uint16_t touch_y[3];
uint16_t touch_strength[3];
uint8_t touch_cnt = 0;
// We wait a bit before initializing the touchscreen
// We wait a bit before initializing the touchscreen on Tulipv4r11
#ifndef TDECK
delay_ms(2000);
#endif
uint8_t touchscreen_ok = 1;

// We have to toggle the RST pin more than once (the driver only does it once)
// So we do that here, wait a second, then init the driver.

#ifdef TULIP4_R11
#if defined TULIP4_R11
fprintf(stderr, "Resetting touch i2c RST pin twice\n");
const gpio_config_t rst_gpio_config = {
.mode = GPIO_MODE_OUTPUT,
Expand Down
15 changes: 14 additions & 1 deletion tulip/esp32s3/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void mp_task(void *pvParameter) {
//usb_init();
#elif CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
#ifdef TDECK
usb_serial_jtag_init();
//usb_serial_jtag_init();
#endif
#endif
#if MICROPY_HW_ENABLE_UART_REPL
Expand Down Expand Up @@ -377,6 +377,17 @@ void app_main(void) {
idle_1_handle = xTaskGetIdleTaskHandleForCPU(1);


#ifdef TDECK
// turn on TDeck peripheral
gpio_config_t peri_gpio_config = {
.mode = GPIO_MODE_OUTPUT,
.pin_bit_mask = 1ULL << TDECK_PERI_GPIO
};
gpio_config(&peri_gpio_config);
gpio_set_level(TDECK_PERI_GPIO, 1);
delay_ms(500);
#endif

#ifndef TDECK
fprintf(stderr,"Starting MIDI on core %d\n", MIDI_TASK_COREID);
xTaskCreatePinnedToCore(run_midi, MIDI_TASK_NAME, MIDI_TASK_STACK_SIZE / sizeof(StackType_t), NULL, MIDI_TASK_PRIORITY, &midi_handle, MIDI_TASK_COREID);
Expand Down Expand Up @@ -411,6 +422,7 @@ void app_main(void) {
#elif defined MAKERFABS
xTaskCreatePinnedToCore(run_gt911, TOUCHSCREEN_TASK_NAME, (TOUCHSCREEN_TASK_STACK_SIZE) / sizeof(StackType_t), NULL, TOUCHSCREEN_TASK_PRIORITY, &touchscreen_handle, TOUCHSCREEN_TASK_COREID);
#elif defined TDECK
delay_ms(500);
xTaskCreatePinnedToCore(run_gt911, TOUCHSCREEN_TASK_NAME, (TOUCHSCREEN_TASK_STACK_SIZE) / sizeof(StackType_t), NULL, TOUCHSCREEN_TASK_PRIORITY, &touchscreen_handle, TOUCHSCREEN_TASK_COREID);
#endif
fflush(stderr);
Expand All @@ -433,6 +445,7 @@ void app_main(void) {
run_sequencer();

#ifdef TDECK
delay_ms(3000); // wait for touchscreen
fprintf(stderr,"Starting T-Deck keyboard on core %d\n", USB_TASK_COREID);
xTaskCreatePinnedToCore(run_tdeck_keyboard, USB_TASK_NAME, (USB_TASK_STACK_SIZE) / sizeof(StackType_t), NULL, USB_TASK_PRIORITY, &usb_handle, USB_TASK_COREID);
fflush(stderr);
Expand Down
13 changes: 4 additions & 9 deletions tulip/esp32s3/tdeck_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ static bool tdeck_trans_done(esp_lcd_panel_io_handle_t panel_io,
vTaskNotifyGiveFromISR(display_handle, &high_task_wakeup);
return high_task_wakeup;
}
extern esp_err_t touch_init(uint8_t alternate);
extern void check_touchscreen();

// Task runner for the display, inits and then spins in a loop processing
void run_tdeck_display(void) {
Expand All @@ -87,14 +89,7 @@ void run_tdeck_display(void) {
gpio_config(&bk_gpio_config);
//gpio_set_level(TDECK_LCD_BK_LIGHT_GPIO, 0);
delay_ms(50);
// turn on TDeck peripheral
gpio_config_t peri_gpio_config = {
.mode = GPIO_MODE_OUTPUT,
.pin_bit_mask = 1ULL << TDECK_PERI_GPIO
};
gpio_config(&peri_gpio_config);
gpio_set_level(TDECK_PERI_GPIO, 1);
delay_ms(50);


// set up SPI
spi_bus_config_t buscfg = {
Expand Down Expand Up @@ -131,7 +126,7 @@ void run_tdeck_display(void) {
esp_lcd_panel_invert_color(panel_handle, true);
esp_lcd_panel_disp_on_off(panel_handle, true);
gpio_set_level(TDECK_LCD_BK_LIGHT_GPIO, 1);

// If you don't clear the screen it'll still show what was left there after reboots.
uint8_t * clear = malloc_caps(H_RES*V_RES*2, MALLOC_CAP_DMA);
memset(clear, 0, H_RES*V_RES*2 );
Expand Down
15 changes: 3 additions & 12 deletions tulip/esp32s3/tdeck_keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,7 @@ void run_tdeck_keyboard() {
int charMappingsSize = sizeof(charMappings) / sizeof(charMappings[0]);
int ctrlMappingsSize = sizeof(ctrlMappings) / sizeof(ctrlMappings[0]);

i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = TDECK_I2C_SDA,
.scl_io_num = TDECK_I2C_SCL,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = 400000,
};
i2c_param_config(I2C_NUM_0, &conf);

ESP_ERROR_CHECK(i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0));
// I2C already initialized on tdeck from the touchscreen

gpio_set_direction(TDECK_TRACKBALL_UP, GPIO_MODE_INPUT);
gpio_pulldown_dis(TDECK_TRACKBALL_UP);
Expand Down Expand Up @@ -199,7 +189,7 @@ void run_tdeck_keyboard() {
gpio_isr_handler_add(TDECK_TRACKBALL_CLICK, gpio_interrupt_handler, (void *)TDECK_TRACKBALL_CLICK);

while (1) {
i2c_master_read_from_device(I2C_NUM_0, LILYGO_KB_SLAVE_ADDRESS, rx_data, 1, pdMS_TO_TICKS(TIMEOUT_MS));
i2c_master_read_from_device(I2C_NUM, LILYGO_KB_SLAVE_ADDRESS, rx_data, 1, pdMS_TO_TICKS(TIMEOUT_MS));
if (rx_data[0] > 0) {
if (rx_data[0] == 224) {
// Toggle ctrl key (shift+microphone)
Expand All @@ -224,6 +214,7 @@ void run_tdeck_keyboard() {
}
}
}
delay_ms(10);
}
}

Expand Down
3 changes: 1 addition & 2 deletions tulip/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ if [ "$TYPE" == "sys" ]; then
fi

# Otherwise, compile all boards. If upload set, upload them
declare -a boards=("TULIP4_R11" "N16R8" "N32R8" "TULIP4_R11_DEBUG")
#declare -a boards=("TDECK")
declare -a boards=("TULIP4_R11" "TDECK" "N16R8" "N32R8")
for i in "${boards[@]}"
do
rm -rf build
Expand Down

0 comments on commit 1e4550d

Please sign in to comment.