Curtis Mattull
/
PANEL_GUI_hello_world
basic functional test of FT810 LCD via SPI
Diff: main.cpp
- Revision:
- 20:92b3e641b306
- Parent:
- 18:d1566d9b6ea1
- Child:
- 21:a50739772892
diff -r 834563fd75b4 -r 92b3e641b306 main.cpp --- a/main.cpp Mon Aug 15 18:06:17 2016 +0000 +++ b/main.cpp Fri Sep 02 16:24:10 2016 +0000 @@ -20,6 +20,11 @@ #include "float.h" #include "SDFileSystem.h" #include "FATFileSystem.h" +#include "DigitalIn.h" +#include "nRF24L01P.h" + + +#define TRANSFER_SIZE 4 // The nRF24L01+ supports transfers from 1 to 32 bytes in size /************************ function prototypes @@ -77,18 +82,22 @@ global objects and variables *************************/ + +nRF24L01P RF ( PTD2, PTD3, PTD1, PTD4, PTC11, PTD0); +// ( mosi, miso, sck, csn, ce, irq) + // create an LCD object -FT800 TFT ( D11, D12, D13, D9, D8, D14 ); -// ( mosi, miso, sclk, ss, intr, pd ); -//Create an SDFileSystem object -SDFileSystem sd ( D11, D12, D13, D10, "sd"); -//SDFileSystem ( mosi, miso, sclk, ss, name); +FT800 TFT ( PTD6, PTD7, PTD5, PTE0, PTB19, PTA1 ); +// ( mosi, miso, sclk, ss, intr, pd ); -DigitalIn sdcard_present(D7); // SD card detect input pin. card_present() is the name of a function within the SDFileSystem Class!!! -AnalogIn analog_in9(A9); // analog 9 pin connected to the PSE input 4 -AnalogIn analog_in8(A8); // analog 9 pin connected to the PFW input 5 -AnalogIn analog_in3(A3); // analog 9 pin connected to the ITV1 input 10 -AnalogIn analog_in2(A2); // analog 9 pin connected to the ITV2 input 11 from usb, starting at 1 +////Create an SDFileSystem object +SDFileSystem sd ( PTD2, PTD3, PTD1, PTC4, "sd"); +////SDFileSystem( mosi, miso, sclk, ss, name); + + + +DigitalIn sdcard_present(PTB16,PullDown); // SD card detect input pin. card_present() is the name of a function within the SDFileSystem Class!!! +AnalogIn analog_in9(A0); const uint8_t font_button = 28, font_title = 31, @@ -119,38 +128,29 @@ *************************/ int main() { -// static const uint8_t display_type = 0x00; //not beyondtek display - static const uint8_t display_type = 0x01; + static const uint8_t display_type = 0x00; //not beyondtek display +// static const uint8_t display_type = 0x01; uint8_t error[4] = { 0x00, // sd_test error 0x00, // load_bitmap error 0x00, // bitmap write error 0x00 }; // gui_manager error - + (*display_rotate[display_type])(); // for proper orientation error[3] = read_calibration(); display_message( error[3], "touch calibration load success!\0", "touch calibration save success!\0"); - TFT.Sleep(100); // Wait ___ to show - - //load jpg into graphics ram - error[1] = Load_jpg("/sd/Logo.jpg", &x_size, &y_size, RAM_G); - display_message( error[1], "load jpg success!\0", "load jpg failed!\0"); - TFT.Sleep(100); // Wait ___ to show - - start_screen("gui by\0"); //unneccessary.. - TFT.Sleep(100); // Wait ___ to show + TFT.Sleep(500); -// //sd card test -// error[0] = sd_test(); -// display_message( error[0], "sd test passed!\0", "sd test failed!\0"); -// TFT.Sleep(250); // Wait ___ to show - -// //display bitmap -// error[2] = draw_bitmap(25,25); -// TFT.Sleep(250); // Wait ___ to show -// display_message( error[2], "draw_bitmap success!\0", "draw_bitmap failed!\0"); -// TFT.Sleep(250); // Wait ___ to show - + // //load jpg into graphics ram +// error[1] = Load_jpg("/sd/Logo.jpg", &x_size, &y_size, RAM_G); +// display_message( error[1], "load jpg success!\0", "load jpg failed!\0"); +// TFT.Sleep(100); // Wait ___ to show + + RF.powerUp(); + RF.setTransferSize( TRANSFER_SIZE ); + RF.setReceiveMode(); + RF.enable(); + //draw initial screen main_menu(0x0,0x0); //program should not return from gui_manager... @@ -492,39 +492,42 @@ *************************/ void mode_c(uint32_t tracker, uint8_t tag) { + static char rxData[TRANSFER_SIZE]; + static char temp_buffer[TRANSFER_SIZE]; + int rxDataCnt = 0; + //ISE40 STATUS DISPLAY static uint16_t data_raw_a9 = 0x0000; - data_raw_a9 = ((analog_in9.read_u16()>>7) & 0x1FF ); +// data_raw_a9 = ((analog_in9.read_u16()>>7) & 0x1FF ); + + // If we've received anything in the nRF24L01+... + if ( RF.readable() ) + { + // ...read the data into the receive buffer + rxDataCnt = RF.read( NRF24L01P_PIPE_P0, rxData, sizeof( rxData ) ); + + // Display the receive buffer contents via the host serial link + for ( int i = 0; rxDataCnt > 0; rxDataCnt--, i++ ) + { + temp_buffer[i] = rxData[i]; + } + } //start new display list TFT.DLstart(); // start a new display command list TFT.DL(TAG(0)); // assign TAG value 0 to everything else + TFT.DL(CLEAR_COLOR_RGB(0,0xFF,0)); // set the clear color to green + TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer - if (data_raw_a9 > 0xFF) // if greater than half of max input - { - //then ise40 "switch on!" - TFT.DL(CLEAR_COLOR_RGB(0,0xFF,0)); // set the clear color to green - TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer - - //message text - TFT.DL(COLOR_RGB(0,0,0)); // set text color to white - TFT.Text((TFT.DispWidth/2), (TFT.DispHeight/2), font_title, OPT_CENTERX, "SWITCH ON!"); // draw Text with font 31 - } - else - { - //then ies40 "switch off!" + //message text + TFT.DL(COLOR_RGB(0,0,0)); // set text color to white + TFT.Text((TFT.DispWidth/2), (TFT.DispHeight/4), font_title, OPT_CENTERX, "nRF24L01+ 2.4GHz wireless testing"); // draw Text with font 31 - TFT.DL(CLEAR_COLOR_RGB(0xFF,0,0)); // set the clear color to green - TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer - - //message text - TFT.DL(COLOR_RGB(0,0,0)); // set text color to white - TFT.Text((TFT.DispWidth/2), (TFT.DispHeight/2), font_title, OPT_CENTERX, "SWITCH OFF!"); // draw Text with font 31 - } - TFT.Text((TFT.DispWidth/2), (TFT.DispHeight/8), font_title, OPT_CENTERX, "ISE40A"); // draw Text with font 31 + TFT.Text((TFT.DispWidth/2), (TFT.DispHeight/2), font_title, OPT_CENTERX, temp_buffer); // draw wireless value with font 31 + //buttons TFT.DL(COLOR_RGB(0xFF, 0xFF, 0xFF)); //this sets the button text color @@ -760,7 +763,7 @@ static ft_char8_t temp_string[32] = {"\0"}; static uint8_t tcal[24]; // touch screen Calibration - while(sdcard_present.read()) { + while(!sdcard_present.read()) { // checks for SD card, if not present hold program until a SD card is inserted error_screen("Error!","Insert SD card!"); // write error screen to LCD } @@ -801,7 +804,7 @@ ****************************************************************************/ uint8_t sd_test(void) { - while(sdcard_present.read()) { + while(!sdcard_present.read()) { // checks for SD card, if not present hold program until a SD card is inserted error_screen("Error!","Insert SD card!"); // write error screen to LCD } @@ -908,7 +911,7 @@ { static int8_t rval = 0x00; - while(sdcard_present.read()) { + while(!sdcard_present.read()) { // checks for SD card, if not present hold program until a SD card is inserted error_screen("Error!","Insert SD card!"); // write error screen to LCD }