My first mbed-os 5.x test project with MAX32630FTHR and Adafruit 2.4" TFT with touch.
Dependencies: BMI160 SPI_STMPE610 USBDevice UniGraphic max32630fthr
My first test program of mbed-os 5.x, using MAX32630FTHR and Adafruit 2.4" TFT with Touch.
On 22-Sep-2017 Monitoring both Acc and Gyr added to the screen 3 Controlling the backlight via STMPE610 GPIO-2 added
Diff: main.cpp
- Revision:
- 2:d810dbdd716b
- Parent:
- 1:a890937c9c30
- Child:
- 3:43de31beea45
--- a/main.cpp Fri Sep 22 01:39:14 2017 +0000 +++ b/main.cpp Fri Sep 22 05:12:59 2017 +0000 @@ -52,6 +52,18 @@ extern void doMaze(void) ; +void backlight(int value) +{ + uint8_t data[2] ; + data[1] = 0x04 ; // GPIO-2 as target pin + if (value) { /* backlight on */ + data[0] = 0x10 ; // GPIO_SET_PIN + } else { + data[0] = 0x11 ; // GPIO_CLR_PIN + } + tsc->writeRegs(data, 2) ; +} + void init_hardware(void) { sakura = new MAX32630FTHR(MAX32630FTHR::VIO_3V3) ; @@ -69,6 +81,14 @@ tsc = new SPI_STMPE610(SPI2_MOSI, SPI2_MISO, SPI2_SCK, PIN_TSC_CS) ; tsc->spi_format(8, 0) ; tsc->calibrate(3552, 400, 439, 3680) ; +/* enable tsc's gpio-2 for backlight */ + uint8_t data[2] ; + data[0] = 0x17 ; // GPIO_ALT_FUNC + data[1] = 0x04 ; // GPIO-2 to be GPIO + tsc->writeRegs(data, 2) ; + data[0] = 0x13 ; // GPIO_DIR + data[1] = 0x04 ; // GPIO-2 as output + tsc->writeRegs(data, 2) ; ledR = new DigitalOut(PIN_LED_R) ; ledG = new DigitalOut(PIN_LED_G) ; @@ -101,6 +121,7 @@ { tft->BusEnable(true) ; // backlight = 0 ; + backlight(0) ; tft->background(White) ; wait(0.1) ; tft->cls() ; @@ -133,6 +154,7 @@ tft->printf("until the next screen starts") ; tft->BusEnable(false) ; // backlight = 1 ; + backlight(1) ; } @@ -141,6 +163,7 @@ //Draw some graphics int i, x[2], y[2] ; // backlight = 0 ; + backlight(0) ; tft->BusEnable(true) ; tft->background(Black); wait(0.1) ; @@ -190,6 +213,7 @@ tft->printf("capability is provided") ; tft->BusEnable(false) ; // backlight = 1 ; + backlight(1) ; } float clip(float src) @@ -223,6 +247,7 @@ float gyr_range ; // backlight = 1 ; + backlight(1) ; acc_range = (float)acc->getAccRange() ; gyr_range = (float)acc->getGyrRange() ; tft->BusEnable(true) ; @@ -337,6 +362,7 @@ break ; case 2: if (prevPage != page) { + backlight(0) ; tft->BusEnable(true) ; tft->background(Black) ; tft->foreground(White) ;