Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BMI160 SPI_STMPE610 USBDevice UniGraphic max32630fthr
Revision 2:d810dbdd716b, committed 2017-09-22
- Comitter:
- Rhyme
- Date:
- Fri Sep 22 05:12:59 2017 +0000
- Parent:
- 1:a890937c9c30
- Child:
- 3:43de31beea45
- Commit message:
- The backlight control of ILI9341 is not connected to the MCU, but gpio-2 of STMPE610 is, so I used STMPE610 to control ILI9341 backlight enable.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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) ;