![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
20 Gennaio 2022 LA0002
Dependencies: mbed QEI DmTftLibrary
Revision 23:b9d23a2f390e, committed 2022-02-10
- Comitter:
- lex9296
- Date:
- Thu Feb 10 09:39:01 2022 +0000
- Parent:
- 22:12c555cade79
- Commit message:
- LA_0005 QEI che compila e legge tutti i Passi RT
Changed in this revision
diff -r 12c555cade79 -r b9d23a2f390e Display/Menu.cpp --- a/Display/Menu.cpp Thu Jan 20 13:26:03 2022 +0000 +++ b/Display/Menu.cpp Thu Feb 10 09:39:01 2022 +0000 @@ -1,6 +1,8 @@ #include <stdio.h> #include "mbed.h" +//#include "QEI.h" + #include "Menu.h" #include "DisplayDriver.h" #include "Eeprom.h" @@ -24,20 +26,20 @@ * touched region (if pressed). CheckScreenFlag keep the status if Touchscreen * has been checked or not, until checked. */ -Ticker CheckScreenTouch; +//Ticker CheckScreenTouch; volatile bool CheckScreenFlag = false; /*! * \brief This ticker give the rythme to refresh a page when continuous info * has to be printed in the same page. */ -Ticker CheckPageRefresh; +//Ticker CheckPageRefresh; volatile bool PageRefresh = false; /*! * \brief This ticker give the rythme to avoid quick menu change */ -Ticker DebouncedScreenTouch; +//Ticker DebouncedScreenTouch; volatile bool ScreenBeenDebounced = false; /*! @@ -79,6 +81,8 @@ BTN6_VALUE_TEXT, BTN7_BORDER, BTN7_MENU_TEXT, + BTN7_LABEL_TEXT, + BTN7_VALUE_TEXT, BTN8_BORDER, BTN8_MENU_TEXT, BTN9_BORDER, @@ -124,7 +128,7 @@ RNG_DS5_LINE, RNG_MST_SCR, }; -#define GRAPH_OBJECTS_COUNT 78 +#define GRAPH_OBJECTS_COUNT 80 GraphObject_t MenuObjects[GRAPH_OBJECTS_COUNT] = { // (Id, Type, Xpos, Ypos, Height, Width, LineW, BackColor, FrontColor, DoFill, FillCol, Source, TouchActive} @@ -160,8 +164,10 @@ {BTN6_MENU_TEXT, GO_TEXT, 15, 258, NULL, 200, 1, BACK_COLOR, MENU_TEXT, false, NULL, NULL, false}, {BTN6_LABEL_TEXT, GO_TEXT, 15, 258, NULL, 64, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, {BTN6_VALUE_TEXT, GO_TEXT, 79, 258, NULL, 152, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, - {BTN7_BORDER, GO_RECTANGLE, 10, 285, 30, 106, 1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL, false}, - {BTN7_MENU_TEXT, GO_TEXT, 15, 293, NULL, 96, 1, BACK_COLOR, MENU_TEXT, false, NULL, NULL, false}, + {BTN7_BORDER, GO_RECTANGLE, 10, 285, 30, 222, 1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL, false}, + {BTN7_MENU_TEXT, GO_TEXT, 15, 293, NULL, 200, 1, BACK_COLOR, MENU_TEXT, false, NULL, NULL, false}, + {BTN7_LABEL_TEXT, GO_TEXT, 15, 293, NULL, 64, 1, BACK_COLOR, TEXT_COLOR, false, NULL, NULL, false}, + {BTN7_VALUE_TEXT, GO_TEXT, 79, 293, NULL, 152, 1, BACK_COLOR, TEXT_VALUE, false, NULL, NULL, false}, {BTN8_BORDER, GO_RECTANGLE, 125, 285, 30, 107, 1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL, false}, {BTN8_MENU_TEXT, GO_TEXT, 130, 293, NULL, 96, 1, BACK_COLOR, MENU_TEXT, false, NULL, NULL, false}, {BTN9_BORDER, GO_RECTANGLE, 125, 40, 30, 107, 1, BACK_COLOR, BUTTON_BORDER, false, NULL, NULL, false}, @@ -233,2303 +239,130 @@ */ //static FreqBase CurrentFreqBase = FB100K; - -void CheckScreen( void ); -void CheckRefresh( void ); -void DebouncedScreen( void ); -void DrawActiveButton( uint8_t buttonId, uint8_t* text1, uint8_t* text2 ); -void ButtonChangeText( uint8_t buttonId, uint8_t* text1, uint8_t* text2 ); -void RemoveButton( uint8_t buttonId ); -void DrawText( uint8_t lineId, uint8_t* text0, uint8_t* text1, uint8_t* text2 ); - - void MenuInit( void ) { DisplayDriverInit( ); GraphObjectDraw( &( MenuObjects[PAGE_BORDER] ), NULL, false, false ); // GraphObjectDraw( &( MenuObjects[TITLE_LINE] ), NULL, false, false ); // MenuSetPage( START_PAGE ); - CheckScreenTouch.attach_us( &CheckScreen, 100000 ); // every 100 ms + +// CheckScreenTouch.attach_us( &CheckScreen, 100000 ); // every 100 ms // Page Utilities only for GPS and proximity sensor : - CheckPageRefresh.attach_us( &CheckRefresh, 1000000 ); // every 1 s +// CheckPageRefresh.attach_us( &CheckRefresh, 1000000 ); // every 1 s } -void StabilusMenu (void) { +extern DigitalIn userButton; +// +extern AnalogIn adc_temp; +extern AnalogIn adc_vref; +extern AnalogIn adc_vbat; +// +//extern QEI Stabilus322699; - uint8_t graphObjectTouched = 0xFF; -// static uint8_t refresh = false; +//void StabilusMenu (uint32_t ms_0001, uint32_t ms_0002, uint32_t ms_0003, int32_t i32_Pulses) { +//void StabilusMenu (uint32_t ms_0001, uint32_t ms_0002, int32_t i32_Pulses) { +//void StabilusMenu (int32_t i32_Pulses) { +//void StabilusMenu (void) { +void StabilusMenu (uint32_t ms_0001, uint32_t ms_0002, uint32_t ms_0003, int32_t i32_Pulses) { +//int32_t i32_Pulses; - if (CheckScreenFlag == true) { - if (ScreenBeenDebounced == false) { - ScreenBeenDebounced = true; - CheckScreenFlag = false; - DebouncedScreenTouch.attach_us (&DebouncedScreen, - 150000); // every 150 ms - GraphObjectTouched (MenuObjects, - GRAPH_OBJECTS_COUNT, - &graphObjectTouched); - } - } +static bool InProgress = false; +uint8_t graphObjectTouched = 0xFF; - StabilusMainPage( graphObjectTouched ); -} - -extern DigitalIn userButton; - -void StabilusMainPage (uint8_t graphObjectTouched) { - + if (InProgress) + return; + else { + static uint32_t ms_0001_prec; + static uint32_t ms_0002_prec; + static uint32_t ms_0003_prec; + static bool PBPushed_prec; + + static bool Touched_Prec; + static int32_t Pulses_Prec; + + static uint16_t x_Prec; + static uint16_t y_Prec; + uint16_t x, y = 0; bool touched = false; bool PBPushed = false; - TouchedXYT (&x, &y, &touched); - sprintf (StringText, - "Screen Touched: %d", touched); - DrawText (TITLE_TEXT, (uint8_t*)StringText, NULL , NULL); - - if (touched == true) { - sprintf (StringText, - "x: %d", x); - DrawActiveButton (BTN2_BORDER, (uint8_t*)StringText, NULL); - - sprintf (StringText, - "Y: %d", y); - DrawActiveButton (BTN3_BORDER, (uint8_t*)StringText, NULL); - } - else { - DrawActiveButton (BTN2_BORDER, (uint8_t*) "No Touch ...", NULL); - DrawActiveButton (BTN3_BORDER, (uint8_t*) "No Touch ...", NULL); - } - - PBPushed = userButton; - sprintf (StringText, - "PB Released: %d", PBPushed); - DrawActiveButton (BTN4_BORDER, (uint8_t*)StringText, NULL); - - // DrawActiveButton( BTN5_BORDER, ( uint8_t* )"Radio Test Modes", NULL ); - // DrawActiveButton( BTN6_BORDER, ( uint8_t* )"Radio Settings", NULL ); - // DrawActiveButton( BTN7_BORDER, ( uint8_t* )"Utilities", NULL ); - -// CurrentPage = START_PAGE; -} - -/* -uint8_t MenuHandler( bool refresh ) -{ - uint8_t graphObjectTouched = 0xFF; - - if( ( CheckScreenFlag == true ) && ( Eeprom.EepromData.DemoSettings.RngStatus != RNG_PROCESS ) ) - { - if( ScreenBeenDebounced == false ) - { - ScreenBeenDebounced = true; - CheckScreenFlag = false; - DebouncedScreenTouch.attach_us( &DebouncedScreen, 150000 ); // every 150 ms - GraphObjectTouched( MenuObjects, GRAPH_OBJECTS_COUNT, &graphObjectTouched ); - } - } - else - { - // in the Utilities page, GPS infos must be refresh each second - if( CurrentPage == PAGE_UTILITIES ) - { - if( PageRefresh == true ) - { - PageRefresh = false; - refresh = true; - } - } - } - - if( refresh == true ) - { - MenuSetPage( CurrentPage ); - } - else if( ( graphObjectTouched != 0xFF ) || ( refresh == true ) ) - { - switch( CurrentPage ) - { - case START_PAGE: - if( graphObjectTouched == BTN2_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_RANGING ) - { - Eeprom.EepromData.DemoSettings.ModulationType = PACKET_TYPE_LORA; - } - EepromLoadSettings( ( RadioPacketTypes_t )Eeprom.EepromData.DemoSettings.ModulationType ); - MenuSetPage( PAGE_PING_PONG ); - } - else if( graphObjectTouched == BTN3_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_RANGING ) - { - Eeprom.EepromData.DemoSettings.ModulationType = PACKET_TYPE_LORA; - } - EepromLoadSettings( ( RadioPacketTypes_t )Eeprom.EepromData.DemoSettings.ModulationType ); - MenuSetPage( PAGE_PER ); - } - else if( graphObjectTouched == BTN4_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - EepromLoadSettings( PACKET_TYPE_RANGING ); - if( Eeprom.EepromData.DemoSettings.Entity == MASTER ) - { - MenuSetPage( PAGE_RANGING_MASTER ); - } - else - { - MenuSetPage( PAGE_RANGING_SLAVE ); - } - } - else if( graphObjectTouched == BTN5_BORDER ) - { - EepromLoadSettings( ( RadioPacketTypes_t )Eeprom.EepromData.DemoSettings.ModulationType ); - MenuSetPage( PAGE_RADIO_TEST ); - } - else if( graphObjectTouched == BTN6_BORDER ) - { - EepromLoadSettings( ( RadioPacketTypes_t )Eeprom.EepromData.DemoSettings.ModulationType ); - MenuSetPage( PAGE_RADIO_PARAM ); - } - else if( graphObjectTouched == BTN7_BORDER ) - { - MenuSetPage( PAGE_UTILITIES ); - } - break; - - case PAGE_PING_PONG: - if( graphObjectTouched == BTN0_BORDER ) - { - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" START", NULL ); - if( Eeprom.EepromData.DemoSettings.Entity == MASTER ) - { - Eeprom.EepromData.DemoSettings.Entity = SLAVE; - ButtonChangeText( BTN0_BORDER, ( uint8_t* )" SLAVE", NULL ); - DrawText( LINE3_COL0_TEXT, NULL, NULL, ( uint8_t* )" " ); - DrawText( LINE4_COL0_TEXT, NULL, NULL, ( uint8_t* )" " ); - DrawText( LINE5_COL0_TEXT, NULL, NULL, ( uint8_t* )" " ); - DrawText( LINE6_COL0_TEXT, NULL, NULL, ( uint8_t* )" " ); - DrawText( LINE7_COL0_TEXT, NULL, NULL, ( uint8_t* )" " ); - } - else - { - Eeprom.EepromData.DemoSettings.Entity = MASTER; - ButtonChangeText( BTN0_BORDER, ( uint8_t* )" MASTER", NULL ); - DrawText( LINE3_COL0_TEXT, NULL, NULL, ( uint8_t* )"MASTER" ); - } - Eeprom.EepromData.DemoSettings.HoldDemo = true; - EepromSaveSettings( DEMO_SETTINGS ); - MenuSetPage( PAGE_PING_PONG ); - } - else if( graphObjectTouched == BTN7_BORDER ) - { - StopDemoApplication( ); - Eeprom.EepromData.DemoSettings.HoldDemo = true; - PreviousPage = START_PAGE; // clear Previous page - MenuSetPage( START_PAGE ); - } - else if( graphObjectTouched == BTN8_BORDER ) - { - if( Eeprom.EepromData.DemoSettings.HoldDemo == true ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = false; - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" STOP", NULL ); - Eeprom.EepromData.DemoSettings.CntPacketTx = 0; - Eeprom.EepromData.DemoSettings.CntPacketRxOK = 0; - Eeprom.EepromData.DemoSettings.CntPacketRxOKSlave = 0; - Eeprom.EepromData.DemoSettings.CntPacketRxKO = 0; - Eeprom.EepromData.DemoSettings.CntPacketRxKOSlave = 0; - Eeprom.EepromData.DemoSettings.RxTimeOutCount = 0; - StopDemoApplication( ); - RunDemoApplicationPingPong( ); - } - else - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" START", NULL ); - StopDemoApplication( ); - wait_ms( 200 ); // debouncing of the touch screen - } - } - else if( graphObjectTouched == BTN9_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - StopDemoApplication( ); - // "CANCEL" or "OK & SAVE" button of PAGE_RADIO_PARAM use - // PreviousPage to set next page. Speed up the navigation. - PreviousPage = PAGE_PING_PONG; - MenuSetPage( PAGE_RADIO_PARAM ); - } - else if( refresh == true ) - { - MenuSetPage( PAGE_PING_PONG ); - } - break; - - case PAGE_PER: - if( graphObjectTouched == BTN0_BORDER ) - { - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" START", NULL ); - if( Eeprom.EepromData.DemoSettings.Entity == MASTER ) - { - Eeprom.EepromData.DemoSettings.Entity = SLAVE; - ButtonChangeText( BTN0_BORDER, ( uint8_t* )" SLAVE", NULL ); - DrawText( LINE4_COL0_TEXT, ( uint8_t* )"Rx OK", NULL, NULL ); - DrawText( LINE5_COL0_TEXT, ( uint8_t* )"Rx KO", NULL, NULL ); - DrawText( LINE6_COL0_TEXT, ( uint8_t* )"PER", NULL, NULL ); - DrawText( LINE8_COL0_TEXT, ( uint8_t* )"Last Rssi", NULL, NULL ); - DrawText( LINE9_COL0_TEXT, ( uint8_t* )"Last SNR", NULL, NULL ); - } - else - { - Eeprom.EepromData.DemoSettings.Entity = MASTER; - ButtonChangeText( BTN0_BORDER, ( uint8_t* )" MASTER", NULL ); - DrawText( LINE4_COL0_TEXT, ( uint8_t* )"Transmitted", ( uint8_t* )GetMenuDemoNumSentPacket( ), NULL ); - DrawText( LINE5_COL0_TEXT, ( uint8_t* )" ", ( uint8_t* )" ", NULL ); - DrawText( LINE6_COL0_TEXT, ( uint8_t* )" ", ( uint8_t* )" ", NULL ); - DrawText( LINE8_COL0_TEXT, ( uint8_t* )" ", ( uint8_t* )" ", NULL ); - DrawText( LINE9_COL0_TEXT, ( uint8_t* )" ", ( uint8_t* )" ", NULL ); - } - Eeprom.EepromData.DemoSettings.HoldDemo = true; - EepromSaveSettings( DEMO_SETTINGS ); - MenuSetPage( PAGE_PER ); - } - else if( graphObjectTouched == BTN7_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - PreviousPage = START_PAGE; // clear Previous page - MenuSetPage( START_PAGE ); - } - else if( graphObjectTouched == BTN8_BORDER ) - { - if( Eeprom.EepromData.DemoSettings.HoldDemo == true ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = false; - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" STOP", NULL ); - StopDemoApplication( ); - Eeprom.EepromData.DemoSettings.CntPacketTx = 0; - Eeprom.EepromData.DemoSettings.CntPacketRxOK = 0; - Eeprom.EepromData.DemoSettings.CntPacketRxKO = 0; - Eeprom.EepromData.DemoSettings.RxTimeOutCount = 0; - RunDemoApplicationPer( ); - } - else - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" START", NULL ); - StopDemoApplication( ); - wait_ms( 200 ); // debouncing of the touch screen - } - } - else if( graphObjectTouched == BTN9_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - StopDemoApplication( ); - // "CANCEL" or "OK & SAVE" button of PAGE_RADIO_PARAM use - // PreviousPage to set next page. Speed up the navigation. - PreviousPage = PAGE_PER; - MenuSetPage( PAGE_RADIO_PARAM ); - } - else if( refresh == true ) - { - MenuSetPage( PAGE_PER ); - } - break; - - case PAGE_RANGING_MASTER: - if( graphObjectTouched == BTN0_BORDER ) - { - Eeprom.EepromData.DemoSettings.Entity = SLAVE; - ButtonChangeText( BTN0_BORDER, ( uint8_t* )" SLAVE", NULL ); - Eeprom.EepromData.DemoSettings.HoldDemo = true; - StopDemoApplication( ); - EepromSaveSettings( DEMO_SETTINGS ); - MenuSetPage( PAGE_RANGING_SLAVE ); - } - else if( graphObjectTouched == BTN7_BORDER ) - { - StopDemoApplication( ); - Eeprom.EepromData.DemoSettings.HoldDemo = true; - PreviousPage = START_PAGE; // clear Previous page - MenuSetPage( START_PAGE ); - } - else if( graphObjectTouched == BTN8_BORDER ) - { - if( Eeprom.EepromData.DemoSettings.HoldDemo == true ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = false; - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" PROCESS..", NULL ); - } - else - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" REFRESH", NULL ); - StopDemoApplication( ); - } - } - else if( graphObjectTouched == BTN9_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - // "SETTINGS" button can occure without "START"/"STOP" button - // also "SETTINGS" should stop the demo - StopDemoApplication( ); - // "CANCEL" or "OK & SAVE" button of PAGE_RADIO_PARAM use - // PreviousPage to set next page. Speed up the navigation. - PreviousPage = PAGE_RANGING_MASTER; - MenuSetPage( PAGE_RADIO_PARAM ); - } - else if( graphObjectTouched == RNG_MST_SCR ) - { - // screen touched .. launch new measure - if( Eeprom.EepromData.DemoSettings.HoldDemo == true ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = false; - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" PROCESS..", NULL ); - } - else - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" REFRESH", NULL ); - StopDemoApplication( ); - } - } - else if( refresh == true ) - { - MenuSetPage( PAGE_RANGING_MASTER ); - } - break; - - case PAGE_RANGING_SLAVE: - if( graphObjectTouched == BTN0_BORDER ) - { - Eeprom.EepromData.DemoSettings.Entity = MASTER; - ButtonChangeText( BTN0_BORDER, ( uint8_t* )" MASTER", NULL ); - Eeprom.EepromData.DemoSettings.HoldDemo = true; - StopDemoApplication( ); - EepromSaveSettings( DEMO_SETTINGS ); - MenuSetPage( PAGE_RANGING_MASTER ); - } - else if( graphObjectTouched == BTN7_BORDER ) - { - StopDemoApplication( ); - Eeprom.EepromData.DemoSettings.HoldDemo = true; - PreviousPage = START_PAGE; // clear Previous page - MenuSetPage( START_PAGE ); - } - else if( graphObjectTouched == BTN8_BORDER ) - { - if( Eeprom.EepromData.DemoSettings.HoldDemo == true ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = false; - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" STOP", NULL ); - StopDemoApplication( ); - RunDemoApplicationRanging( ); - } - else - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" START", NULL ); - StopDemoApplication( ); - } - } - else if( graphObjectTouched == BTN9_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - // "SETTINGS" button can occure without "START"/"STOP" button - // also "SETTINGS" should stop the demo - StopDemoApplication( ); - // "CANCEL" or "OK & SAVE" button of PAGE_RADIO_PARAM use - // PreviousPage to set next page. Speed up the navigation. - PreviousPage = PAGE_RANGING_SLAVE; - MenuSetPage( PAGE_RADIO_PARAM ); - } - else if( refresh == true ) - { - MenuSetPage( PAGE_RANGING_SLAVE ); - } - break; - - case PAGE_RADIO_PARAM: - if( graphObjectTouched == BTN0_BORDER ) - { - if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_LORA ) - { - Eeprom.EepromData.DemoSettings.ModulationType = PACKET_TYPE_FLRC; - } - else if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_FLRC ) - { - Eeprom.EepromData.DemoSettings.ModulationType = PACKET_TYPE_GFSK; - } - else if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_GFSK ) - { - if( PreviousPage == START_PAGE ) - { - Eeprom.EepromData.DemoSettings.ModulationType = PACKET_TYPE_RANGING; - } - else - { - Eeprom.EepromData.DemoSettings.ModulationType = PACKET_TYPE_LORA; - } - } - else // PACKET_TYPE_RANGING - { - if( PreviousPage == START_PAGE ) - { - Eeprom.EepromData.DemoSettings.ModulationType = PACKET_TYPE_LORA; - } - } - EepromLoadSettings( ( RadioPacketTypes_t )Eeprom.EepromData.DemoSettings.ModulationType ); - MenuSetPage( PAGE_RADIO_PARAM ); - } - else if( graphObjectTouched == BTN9_BORDER ) - { - EepromSetRangingDefaultSettings( ); - EepromLoadSettings( PACKET_TYPE_RANGING ); - ButtonChangeText( BTN3_BORDER, NULL, ( uint8_t* )GetRadioModulationParameters1( ) ); - ButtonChangeText( BTN4_BORDER, NULL, ( uint8_t* )GetRadioModulationParameters2( ) ); - ButtonChangeText( BTN5_BORDER, NULL, ( uint8_t* )GetRadioModulationParameters3( ) ); - } - else if( graphObjectTouched == BTN1_BORDER ) - { - MenuSetPage( PAGE_RADIO_PARAM_FREQ ); - } - else if( graphObjectTouched == BTN2_BORDER ) - { - Eeprom.EepromData.DemoSettings.TxPower += 1; - if( Eeprom.EepromData.DemoSettings.TxPower > DEMO_POWER_TX_MAX ) - { - Eeprom.EepromData.DemoSettings.TxPower = DEMO_POWER_TX_MIN; - } - ButtonChangeText( BTN2_BORDER, NULL, ( uint8_t* )GetRadioTxPower( ) ); - } - else if( graphObjectTouched == BTN3_BORDER ) - { - if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_LORA ) - { - if( Eeprom.EepromData.DemoSettings.ModulationParam1 < LORA_SF12 ) - { - Eeprom.EepromData.DemoSettings.ModulationParam1 = Eeprom.EepromData.DemoSettings.ModulationParam1 + 0x10; - } - else - { - Eeprom.EepromData.DemoSettings.ModulationParam1 = LORA_SF5; - } - } - else if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_RANGING ) - { - if( Eeprom.EepromData.DemoSettings.ModulationParam1 < LORA_SF10 ) - { - Eeprom.EepromData.DemoSettings.ModulationParam1 = Eeprom.EepromData.DemoSettings.ModulationParam1 + 0x10; - } - else - { - Eeprom.EepromData.DemoSettings.ModulationParam1 = LORA_SF5; - } - } - else if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_FLRC ) - { - switch( Eeprom.EepromData.DemoSettings.ModulationParam1 ) - { - case FLRC_BR_1_300_BW_1_2: - Eeprom.EepromData.DemoSettings.ModulationParam1 = FLRC_BR_1_040_BW_1_2; - break; - - case FLRC_BR_1_040_BW_1_2: - Eeprom.EepromData.DemoSettings.ModulationParam1 = FLRC_BR_0_650_BW_0_6; - break; - - case FLRC_BR_0_650_BW_0_6: - Eeprom.EepromData.DemoSettings.ModulationParam1 = FLRC_BR_0_520_BW_0_6; - break; - - case FLRC_BR_0_520_BW_0_6: - Eeprom.EepromData.DemoSettings.ModulationParam1 = FLRC_BR_0_325_BW_0_3; - break; - - case FLRC_BR_0_325_BW_0_3: - Eeprom.EepromData.DemoSettings.ModulationParam1 = FLRC_BR_0_260_BW_0_3; - break; - - case FLRC_BR_0_260_BW_0_3: - Eeprom.EepromData.DemoSettings.ModulationParam1 = FLRC_BR_1_300_BW_1_2; - break; - } - } - else // PACKET_TYPE_GFSK - { - switch( Eeprom.EepromData.DemoSettings.ModulationParam1 ) - { - case GFSK_BLE_BR_2_000_BW_2_4: - Eeprom.EepromData.DemoSettings.ModulationParam1 = GFSK_BLE_BR_1_600_BW_2_4; - break; - - case GFSK_BLE_BR_1_600_BW_2_4: - Eeprom.EepromData.DemoSettings.ModulationParam1 = GFSK_BLE_BR_1_000_BW_2_4; - break; - - case GFSK_BLE_BR_1_000_BW_2_4: - Eeprom.EepromData.DemoSettings.ModulationParam1 = GFSK_BLE_BR_1_000_BW_1_2; - break; - - case GFSK_BLE_BR_1_000_BW_1_2: - Eeprom.EepromData.DemoSettings.ModulationParam1 = GFSK_BLE_BR_0_800_BW_2_4; - break; - - case GFSK_BLE_BR_0_800_BW_2_4: - Eeprom.EepromData.DemoSettings.ModulationParam1 = GFSK_BLE_BR_0_800_BW_1_2; - break; - - case GFSK_BLE_BR_0_800_BW_1_2: - Eeprom.EepromData.DemoSettings.ModulationParam1 = GFSK_BLE_BR_0_500_BW_1_2; - break; - - case GFSK_BLE_BR_0_500_BW_1_2: - Eeprom.EepromData.DemoSettings.ModulationParam1 = GFSK_BLE_BR_0_500_BW_0_6; - break; - - case GFSK_BLE_BR_0_500_BW_0_6: - Eeprom.EepromData.DemoSettings.ModulationParam1 = GFSK_BLE_BR_0_400_BW_1_2; - break; - - case GFSK_BLE_BR_0_400_BW_1_2: - Eeprom.EepromData.DemoSettings.ModulationParam1 = GFSK_BLE_BR_0_400_BW_0_6; - break; - - case GFSK_BLE_BR_0_400_BW_0_6: - Eeprom.EepromData.DemoSettings.ModulationParam1 = GFSK_BLE_BR_0_250_BW_0_6; - break; - - case GFSK_BLE_BR_0_250_BW_0_6: - Eeprom.EepromData.DemoSettings.ModulationParam1 = GFSK_BLE_BR_0_250_BW_0_3; - break; - - case GFSK_BLE_BR_0_250_BW_0_3: - Eeprom.EepromData.DemoSettings.ModulationParam1 = GFSK_BLE_BR_0_125_BW_0_3; - break; - - case GFSK_BLE_BR_0_125_BW_0_3: - Eeprom.EepromData.DemoSettings.ModulationParam1 = GFSK_BLE_BR_2_000_BW_2_4; - break; - } - } - ButtonChangeText( BTN3_BORDER, NULL, ( uint8_t* )GetRadioModulationParameters1( ) ); - } - else if( graphObjectTouched == BTN4_BORDER ) - { - if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_LORA ) - { - switch( Eeprom.EepromData.DemoSettings.ModulationParam2 ) - { - case LORA_BW_0200: - Eeprom.EepromData.DemoSettings.ModulationParam2 = LORA_BW_0400; - break; - - case LORA_BW_0400: - Eeprom.EepromData.DemoSettings.ModulationParam2 = LORA_BW_0800; - break; - - case LORA_BW_0800: - Eeprom.EepromData.DemoSettings.ModulationParam2 = LORA_BW_1600; - break; + InProgress = true; - case LORA_BW_1600: - Eeprom.EepromData.DemoSettings.ModulationParam2 = LORA_BW_0200; - break; - } - } - else if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_RANGING ) - { - switch( Eeprom.EepromData.DemoSettings.ModulationParam2 ) - { - case LORA_BW_0400: - Eeprom.EepromData.DemoSettings.ModulationParam2 = LORA_BW_0800; - break; - - case LORA_BW_0800: - Eeprom.EepromData.DemoSettings.ModulationParam2 = LORA_BW_1600; - break; - - case LORA_BW_1600: - Eeprom.EepromData.DemoSettings.ModulationParam2 = LORA_BW_0400; - break; - } - } - else if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_FLRC ) - { - if( Eeprom.EepromData.DemoSettings.ModulationParam2 < FLRC_CR_1_0 ) - { - Eeprom.EepromData.DemoSettings.ModulationParam2 = Eeprom.EepromData.DemoSettings.ModulationParam2 + 2;; - } - else - { - Eeprom.EepromData.DemoSettings.ModulationParam2 = FLRC_CR_1_2; - } - } - else // PACKET_TYPE_GFSK - { - if( Eeprom.EepromData.DemoSettings.ModulationParam2 < GFSK_BLE_MOD_IND_4_00 ) - { - Eeprom.EepromData.DemoSettings.ModulationParam2++; - } - else - { - Eeprom.EepromData.DemoSettings.ModulationParam2 = GFSK_BLE_MOD_IND_0_35; - } - } - ButtonChangeText( BTN4_BORDER, NULL, ( uint8_t* )GetRadioModulationParameters2( ) ); - } - else if( graphObjectTouched == BTN5_BORDER ) - { - if( ( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_LORA ) || \ - ( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_RANGING ) ) - { - if( Eeprom.EepromData.DemoSettings.ModulationParam3 < LORA_CR_LI_4_7 ) - { - Eeprom.EepromData.DemoSettings.ModulationParam3++; - } - else - { - Eeprom.EepromData.DemoSettings.ModulationParam3 = LORA_CR_4_5; - } - } - else // PACKET_TYPE_GFSK and PACKET_TYPE_FLRC - { - if( Eeprom.EepromData.DemoSettings.ModulationParam3 < RADIO_MOD_SHAPING_BT_0_5 ) - { - Eeprom.EepromData.DemoSettings.ModulationParam3 = Eeprom.EepromData.DemoSettings.ModulationParam3 + 0x10; - } - else - { - Eeprom.EepromData.DemoSettings.ModulationParam3 = RADIO_MOD_SHAPING_BT_OFF; - } - } - ButtonChangeText( BTN5_BORDER, NULL, ( uint8_t* )GetRadioModulationParameters3( ) ); - } - else if( graphObjectTouched == BTN6_BORDER ) - { - if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_LORA ) - { - if( Eeprom.EepromData.DemoSettings.PacketParam3 < 32 ) - { - Eeprom.EepromData.DemoSettings.PacketParam3++; - } - else if( Eeprom.EepromData.DemoSettings.PacketParam3 <= ( DEMO_GFS_LORA_MAX_PAYLOAD - 8 ) ) - { - Eeprom.EepromData.DemoSettings.PacketParam3 += 8; - } - else - { - Eeprom.EepromData.DemoSettings.PacketParam3 = DEMO_MIN_PAYLOAD; - } - } - else if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_FLRC ) - { - if( Eeprom.EepromData.DemoSettings.PacketParam5 < 32 ) - { - Eeprom.EepromData.DemoSettings.PacketParam5++; - } - else if( Eeprom.EepromData.DemoSettings.PacketParam5 <= ( DEMO_FLRC_MAX_PAYLOAD - 8 ) ) - { - Eeprom.EepromData.DemoSettings.PacketParam5 += 8; - } - else - { - Eeprom.EepromData.DemoSettings.PacketParam5 = DEMO_MIN_PAYLOAD; - } - } - else if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_GFSK ) - { - if( Eeprom.EepromData.DemoSettings.PacketParam5 < 32 ) - { - Eeprom.EepromData.DemoSettings.PacketParam5++; - } - else if( Eeprom.EepromData.DemoSettings.PacketParam5 <= ( DEMO_GFS_LORA_MAX_PAYLOAD - 8 ) ) - { - Eeprom.EepromData.DemoSettings.PacketParam5 += 8; - } - else - { - Eeprom.EepromData.DemoSettings.PacketParam5 = DEMO_MIN_PAYLOAD; - } - } - if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_RANGING ) - { - MenuSetPage( PAGE_RANGING_PARAM ); - } - else - { - ButtonChangeText( BTN6_BORDER, NULL, ( uint8_t* )GetRadioPayloadLength( ) ); - } - } - else if( graphObjectTouched == BTN7_BORDER ) - { - uint8_t modTmp = Eeprom.EepromData.DemoSettings.ModulationType; - - EepromMcuReadBuffer( 0, Eeprom.Buffer, EEPROM_BUFFER_SIZE ); - EepromLoadGeneralSettings( ); - EepromLoadSettings( ( RadioPacketTypes_t )modTmp ); - MenuSetPage( PreviousPage ); - } - else if( graphObjectTouched == BTN8_BORDER ) - { - switch( Eeprom.EepromData.DemoSettings.ModulationType ) - { - case PACKET_TYPE_RANGING: - EepromSaveSettings( RADIO_RANGING_PARAMS ); - break; - - case PACKET_TYPE_LORA: - EepromSaveSettings( RADIO_LORA_PARAMS ); - break; - - case PACKET_TYPE_FLRC: - EepromSaveSettings( RADIO_FLRC_PARAMS ); - break; - - case PACKET_TYPE_GFSK: - EepromSaveSettings( RADIO_GFSK_PARAMS ); - break; - } - EepromSaveSettings( DEMO_SETTINGS ); - MenuSetPage( PreviousPage ); - } - break; - - case PAGE_RANGING_PARAM: - if( graphObjectTouched == BTN1_BORDER ) - { - Eeprom.EepromData.DemoSettings.RngRequestCount += 5; - if( Eeprom.EepromData.DemoSettings.RngRequestCount >= DEMO_RNG_CHANNELS_COUNT_MAX ) - { - Eeprom.EepromData.DemoSettings.RngRequestCount = DEMO_RNG_CHANNELS_COUNT_MIN; - } - ButtonChangeText( BTN1_BORDER, NULL, ( uint8_t* )GetRangingRequestCount( ) ); - } - else if( graphObjectTouched == BTN2_BORDER ) - { - switch( Eeprom.EepromData.DemoSettings.RngAddress ) - { - case DEMO_RNG_ADDR_1: - Eeprom.EepromData.DemoSettings.RngAddress = DEMO_RNG_ADDR_2; - break; - - case DEMO_RNG_ADDR_2: - Eeprom.EepromData.DemoSettings.RngAddress = DEMO_RNG_ADDR_3; - break; - - case DEMO_RNG_ADDR_3: - Eeprom.EepromData.DemoSettings.RngAddress = DEMO_RNG_ADDR_4; - break; - - case DEMO_RNG_ADDR_4: - Eeprom.EepromData.DemoSettings.RngAddress = DEMO_RNG_ADDR_5; - break; - - case DEMO_RNG_ADDR_5: - Eeprom.EepromData.DemoSettings.RngAddress = DEMO_RNG_ADDR_1; - break; - } - ButtonChangeText( BTN2_BORDER, NULL, ( uint8_t* )GetRangingAddress( ) ); - } - else if( graphObjectTouched == BTN3_BORDER ) - { - switch( Eeprom.EepromData.DemoSettings.RngAntenna ) - { - case DEMO_RNG_ANT_1: - Eeprom.EepromData.DemoSettings.RngAntenna = DEMO_RNG_ANT_0; - break; - - case DEMO_RNG_ANT_0: - Eeprom.EepromData.DemoSettings.RngAntenna = DEMO_RNG_ANT_BOTH; - break; - - case DEMO_RNG_ANT_BOTH: - Eeprom.EepromData.DemoSettings.RngAntenna = DEMO_RNG_ANT_1; - break; - } - ButtonChangeText( BTN3_BORDER, NULL, ( uint8_t* )GetRangingAntenna( ) ); - } - else if( graphObjectTouched == BTN4_BORDER ) - { - Eeprom.EepromData.DemoSettings.RngUnit++; - if( Eeprom.EepromData.DemoSettings.RngUnit > DEMO_RNG_UNIT_SEL_MI ) - { - Eeprom.EepromData.DemoSettings.RngUnit = DEMO_RNG_UNIT_SEL_M; - } - ButtonChangeText( BTN4_BORDER, NULL, ( uint8_t* )GetRangingUnit( ) ); - } - else if( graphObjectTouched == BTN7_BORDER ) - { - EepromMcuReadBuffer( 0, Eeprom.Buffer, EEPROM_BUFFER_SIZE ); - EepromLoadGeneralSettings( ); - EepromLoadSettings( PACKET_TYPE_RANGING ); - MenuSetPage( PAGE_RADIO_PARAM ); - } - else if( graphObjectTouched == BTN8_BORDER ) - { - EepromSaveSettings( RADIO_RANGING_PARAMS ); - MenuSetPage( PAGE_RADIO_PARAM ); - } - break; - - case PAGE_RADIO_PARAM_FREQ: - if( graphObjectTouched == BTN0_BORDER ) - { - Eeprom.EepromData.DemoSettings.Frequency -= CurrentFreqBase; - if( Eeprom.EepromData.DemoSettings.Frequency < DEMO_CENTRAL_FREQ_MIN ) - { - Eeprom.EepromData.DemoSettings.Frequency = DEMO_CENTRAL_FREQ_MIN; - } - ButtonChangeText( BTN2_BORDER, NULL, ( uint8_t* )GetRadioFrequency( ) ); - } - else if( graphObjectTouched == BTN1_BORDER ) - { - switch( CurrentFreqBase ) - { - case FB1: - CurrentFreqBase = FB10; - break; - - case FB10: - CurrentFreqBase = FB100; - break; - - case FB100: - CurrentFreqBase = FB1K; - break; - - case FB1K: - CurrentFreqBase = FB10K; - break; - - case FB10K: - CurrentFreqBase = FB100K; - break; - - case FB100K: - CurrentFreqBase = FB1M; - break; - - case FB1M: - CurrentFreqBase = FB10M; - break; - - case FB10M: - CurrentFreqBase = FB1; - break; - } - ButtonChangeText( BTN1_BORDER, NULL, ( uint8_t* )GetRadioFreqBase( ) ); - } - else if( graphObjectTouched == BTN3_BORDER ) - { - Eeprom.EepromData.DemoSettings.Frequency = DEMO_CENTRAL_FREQ_PRESET1; - MenuSetPage( PAGE_RADIO_PARAM ); - } - else if( graphObjectTouched == BTN4_BORDER ) - { - Eeprom.EepromData.DemoSettings.Frequency = DEMO_CENTRAL_FREQ_PRESET2; - MenuSetPage( PAGE_RADIO_PARAM ); - } - else if( graphObjectTouched == BTN5_BORDER ) - { - Eeprom.EepromData.DemoSettings.Frequency = DEMO_CENTRAL_FREQ_PRESET3; - MenuSetPage( PAGE_RADIO_PARAM ); - } - else if( graphObjectTouched == BTN7_BORDER ) - { - memcpy( &( Eeprom.EepromData.DemoSettings.Frequency ), Eeprom.Buffer + APP_FREQ_EEPROM_ADDR, 4 ); - MenuSetPage( PAGE_RADIO_PARAM ); - } - else if( graphObjectTouched == BTN8_BORDER ) - { - MenuSetPage( PAGE_RADIO_PARAM ); - } - else if( graphObjectTouched == BTN9_BORDER ) - { - Eeprom.EepromData.DemoSettings.Frequency += CurrentFreqBase; - if( Eeprom.EepromData.DemoSettings.Frequency > DEMO_CENTRAL_FREQ_MAX ) - { - Eeprom.EepromData.DemoSettings.Frequency = DEMO_CENTRAL_FREQ_MAX; - } - ButtonChangeText( BTN2_BORDER, NULL, ( uint8_t* )GetRadioFrequency( ) ); - } - break; - - case PAGE_UTILITIES: - if( graphObjectTouched == BTN0_BORDER ) - { - FactoryReset( ); - MenuSetPage( START_PAGE ); - } - else if( graphObjectTouched == BTN4_BORDER ) - { - if( Eeprom.EepromData.DemoSettings.RadioPowerMode == USE_LDO ) - { - Eeprom.EepromData.DemoSettings.RadioPowerMode = USE_DCDC; - } - else - { - Eeprom.EepromData.DemoSettings.RadioPowerMode = USE_LDO; - } - ButtonChangeText( BTN4_BORDER, NULL, ( uint8_t* )GetMenuDemoRadioPowerMode( ) ); - } - else if( graphObjectTouched == BTN5_BORDER ) - { - switch( Eeprom.EepromData.DemoSettings.MaxNumPacket ) - { - case 0: - Eeprom.EepromData.DemoSettings.MaxNumPacket = 100; - break; - - case 100: - Eeprom.EepromData.DemoSettings.MaxNumPacket = 200; - break; - - case 200: - Eeprom.EepromData.DemoSettings.MaxNumPacket = 500; - break; - - case 500: - Eeprom.EepromData.DemoSettings.MaxNumPacket = 1000; - break; - - case 1000: - Eeprom.EepromData.DemoSettings.MaxNumPacket = 0; - break; - } - ButtonChangeText( BTN5_BORDER, NULL, ( uint8_t* )GetMenuDemoMaxNumPacket( ) ); - } - else if( graphObjectTouched == BTN6_BORDER ) - { - if( Eeprom.EepromData.DemoSettings.AntennaSwitch == 0 ) - { - Eeprom.EepromData.DemoSettings.AntennaSwitch = 1; - ButtonChangeText( BTN6_BORDER, NULL, ( uint8_t* )"ANT0" ); - } - else - { - Eeprom.EepromData.DemoSettings.AntennaSwitch = 0; - ButtonChangeText( BTN6_BORDER, NULL, ( uint8_t* )"ANT1" ); - } - } - else if( graphObjectTouched == BTN7_BORDER ) - { - uint8_t modTmp = Eeprom.EepromData.DemoSettings.ModulationType; - - EepromMcuReadBuffer( 0, Eeprom.Buffer, EEPROM_BUFFER_SIZE ); - EepromLoadGeneralSettings( ); - EepromLoadSettings( ( RadioPacketTypes_t )modTmp ); - MenuSetPage( START_PAGE ); - } - else if( graphObjectTouched == BTN8_BORDER ) - { - EepromSaveSettings( DEMO_SETTINGS ); - MenuSetPage( START_PAGE ); - } - else if( refresh == true ) - { - MenuSetPage( PAGE_UTILITIES ); - } - break; - - case PAGE_RADIO_TEST: - if( graphObjectTouched == BTN1_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - MenuSetPage( PAGE_SLEEP_MODE ); - } - else if( graphObjectTouched == BTN2_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - MenuSetPage( PAGE_STBY_RC_MODE ); - } - else if( graphObjectTouched == BTN3_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - MenuSetPage( PAGE_STBY_XOSC_MODE ); - } - else if( graphObjectTouched == BTN4_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - MenuSetPage( PAGE_TX_CW ); - } - else if( graphObjectTouched == BTN5_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - MenuSetPage( PAGE_CONT_MODULATION ); - } - else if( graphObjectTouched == BTN7_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - MenuSetPage( START_PAGE ); - } - break; - - case PAGE_SLEEP_MODE: - if( graphObjectTouched == BTN7_BORDER ) - { - StopDemoApplication( ); - Eeprom.EepromData.DemoSettings.HoldDemo = true; - PreviousPage = START_PAGE; // clear Previous page - MenuSetPage( START_PAGE ); - } - else if( graphObjectTouched == BTN8_BORDER ) - { - if( Eeprom.EepromData.DemoSettings.HoldDemo == true ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = false; - StopDemoApplication( ); - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" STOP", NULL ); - RunDemoSleepMode( ); - } - else - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - StopDemoApplication( ); - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" START", NULL ); - MenuSetPage( PAGE_SLEEP_MODE ); - } - } - else if( graphObjectTouched == BTN9_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - // "CANCEL" or "OK & SAVE" button of PAGE_RADIO_PARAM use - // PreviousPage to set next page. Speed up the navigation. - PreviousPage = PAGE_SLEEP_MODE; - MenuSetPage( PAGE_RADIO_PARAM ); - } - break; - - case PAGE_STBY_RC_MODE: - if( graphObjectTouched == BTN7_BORDER ) - { - StopDemoApplication( ); - Eeprom.EepromData.DemoSettings.HoldDemo = true; - PreviousPage = START_PAGE; // clear Previous page - MenuSetPage( START_PAGE ); - } - else if( graphObjectTouched == BTN8_BORDER ) - { - if( Eeprom.EepromData.DemoSettings.HoldDemo == true ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = false; - StopDemoApplication( ); - RunDemoStandbyRcMode( ); - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" STOP", NULL ); - } - else - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - StopDemoApplication( ); - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" START", NULL ); - } - } - else if( graphObjectTouched == BTN9_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - // "CANCEL" or "OK & SAVE" button of PAGE_RADIO_PARAM use - // PreviousPage to set next page. Speed up the navigation. - PreviousPage = PAGE_STBY_RC_MODE; - MenuSetPage( PAGE_RADIO_PARAM ); - } - break; - - case PAGE_STBY_XOSC_MODE: - if( graphObjectTouched == BTN7_BORDER ) - { - StopDemoApplication( ); - Eeprom.EepromData.DemoSettings.HoldDemo = true; - PreviousPage = START_PAGE; // clear Previous page - MenuSetPage( START_PAGE ); - } - else if( graphObjectTouched == BTN8_BORDER ) - { - if( Eeprom.EepromData.DemoSettings.HoldDemo == true ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = false; - StopDemoApplication( ); - RunDemoStandbyXoscMode( ); - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" STOP", NULL ); - } - else - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - StopDemoApplication( ); - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" START", NULL ); - } - } - else if( graphObjectTouched == BTN9_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - // "CANCEL" or "OK & SAVE" button of PAGE_RADIO_PARAM use - // PreviousPage to set next page. Speed up the navigation. - PreviousPage = PAGE_STBY_XOSC_MODE; - MenuSetPage( PAGE_RADIO_PARAM ); - } - break; - - case PAGE_TX_CW: - if( graphObjectTouched == BTN7_BORDER ) - { - StopDemoApplication( ); - Eeprom.EepromData.DemoSettings.HoldDemo = true; - PreviousPage = START_PAGE; // clear Previous page - MenuSetPage( START_PAGE ); - } - else if( graphObjectTouched == BTN8_BORDER ) - { - if( Eeprom.EepromData.DemoSettings.HoldDemo == true ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = false; - StopDemoApplication( ); - RunDemoTxCw( ); - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" STOP", NULL ); - } - else - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - StopDemoApplication( ); - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" START", NULL ); - } - } - else if( graphObjectTouched == BTN9_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - // "CANCEL" or "OK & SAVE" button of PAGE_RADIO_PARAM use - // PreviousPage to set next page. Speed up the navigation. - PreviousPage = PAGE_TX_CW; - MenuSetPage( PAGE_RADIO_PARAM ); - } - break; + GraphObjectTouched (MenuObjects, + GRAPH_OBJECTS_COUNT, + &graphObjectTouched); - case PAGE_CONT_MODULATION: - if( graphObjectTouched == BTN7_BORDER ) - { - StopDemoApplication( ); - Eeprom.EepromData.DemoSettings.HoldDemo = true; - PreviousPage = START_PAGE; // clear Previous page - MenuSetPage( START_PAGE ); - } - else if( graphObjectTouched == BTN8_BORDER ) - { - if( Eeprom.EepromData.DemoSettings.HoldDemo == true ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = false; - StopDemoApplication( ); - RunDemoTxContinuousModulation( ); - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" STOP", NULL ); - } - else - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - StopDemoApplication( ); - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" START", NULL ); - } - } - else if( graphObjectTouched == BTN9_BORDER ) - { - Eeprom.EepromData.DemoSettings.HoldDemo = true; - // "CANCEL" or "OK & SAVE" button of PAGE_RADIO_PARAM use - // PreviousPage to set next page. Speed up the navigation. - PreviousPage = PAGE_CONT_MODULATION; - MenuSetPage( PAGE_RADIO_PARAM ); - } - break; - } - } - return CurrentPage; -} -*/ - -/* -void MenuSetPage( uint8_t page ) -{ - if( page != CurrentPage ) - { - // remove all button and text (except title, page border and line) - // and disable all button (touchActive = false). - GraphObject_t clearRect = { NULL, GO_RECTANGLE, 3, 35, 282, 230, 1, \ - BACK_COLOR, BACK_COLOR, true, BACK_COLOR, \ - NULL, false }; - - GraphObjectClear( &clearRect, true ); - for( uint8_t i = 0; i < GRAPH_OBJECTS_COUNT; i++ ) - { - MenuObjects[i].TouchActive = false; - } - } - - switch( page ) - { - case START_PAGE: - DrawText( TITLE_TEXT, ( uint8_t* )" SX1280 Demo Kit", NULL, NULL ); - DisplayDriverDrawLogo( SemtechLogo, 20, 37 ); - DrawActiveButton( BTN2_BORDER, ( uint8_t* )"DEMO Ping Pong", NULL ); - DrawActiveButton( BTN3_BORDER, ( uint8_t* )"DEMO PER FHSS", NULL ); - DrawActiveButton( BTN4_BORDER, ( uint8_t* )"Outdoor ranging demo", NULL ); - DrawActiveButton( BTN5_BORDER, ( uint8_t* )"Radio Test Modes", NULL ); - DrawActiveButton( BTN6_BORDER, ( uint8_t* )"Radio Settings", NULL ); - DrawActiveButton( BTN7_BORDER, ( uint8_t* )"Utilities", NULL ); - CurrentPage = START_PAGE; - break; - - case PAGE_PING_PONG: - if( CurrentPage == PAGE_PING_PONG ) - { - if( Eeprom.EepromData.DemoSettings.HoldDemo == true ) - { - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" START", NULL ); - } - if( Eeprom.EepromData.DemoSettings.Entity == MASTER ) - { - DrawText( LINE4_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoRxOkSlave( ), ( uint8_t* )GetMenuDemoRxOk( ) ); - DrawText( LINE5_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoRxKoSlave( ), ( uint8_t* )GetMenuDemoRxKo( ) ); - DrawText( LINE6_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoResultPerCent1( Eeprom.EepromData.DemoSettings.CntPacketRxOKSlave, Eeprom.EepromData.DemoSettings.CntPacketRxOKSlave + Eeprom.EepromData.DemoSettings.CntPacketRxKOSlave ), \ - ( uint8_t* )GetMenuDemoResultPerCent2( Eeprom.EepromData.DemoSettings.CntPacketRxOK, Eeprom.EepromData.DemoSettings.CntPacketRxOK + Eeprom.EepromData.DemoSettings.CntPacketRxKO + Eeprom.EepromData.DemoSettings.RxTimeOutCount ) ); - DrawText( LINE7_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoResultPerCent1( Eeprom.EepromData.DemoSettings.CntPacketRxKOSlave, Eeprom.EepromData.DemoSettings.CntPacketRxOKSlave + Eeprom.EepromData.DemoSettings.CntPacketRxKOSlave ), \ - ( uint8_t* )GetMenuDemoResultPerCent2( Eeprom.EepromData.DemoSettings.CntPacketRxKO + Eeprom.EepromData.DemoSettings.RxTimeOutCount, Eeprom.EepromData.DemoSettings.CntPacketRxOK + Eeprom.EepromData.DemoSettings.CntPacketRxKO + Eeprom.EepromData.DemoSettings.RxTimeOutCount ) ); - DrawText( LINE8_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoRssi( ), NULL ); - DrawText( LINE9_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoSnr( ), NULL ); - } - else - { - DrawText( LINE4_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoRxOk( ), NULL ); - DrawText( LINE5_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoRxKo( ), NULL ); - DrawText( LINE6_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoResultPerCent1( Eeprom.EepromData.DemoSettings.CntPacketRxOK, Eeprom.EepromData.DemoSettings.CntPacketRxOK + Eeprom.EepromData.DemoSettings.CntPacketRxKO + Eeprom.EepromData.DemoSettings.RxTimeOutCount ), NULL ); - DrawText( LINE7_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoResultPerCent1( Eeprom.EepromData.DemoSettings.CntPacketRxKO + Eeprom.EepromData.DemoSettings.RxTimeOutCount, Eeprom.EepromData.DemoSettings.CntPacketRxOK + Eeprom.EepromData.DemoSettings.CntPacketRxKO + Eeprom.EepromData.DemoSettings.RxTimeOutCount ), NULL ); - DrawText( LINE8_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoRssi( ), NULL ); - DrawText( LINE9_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoSnr( ), NULL ); - } - } - else - { - DrawText( TITLE_TEXT, ( uint8_t* )" PING PONG Demo", NULL, NULL ); - DisplayCurrentRadioParams( PAGE_PING_PONG ); - DrawText( LINE3_COL0_TEXT, ( uint8_t* )GetTotalPackets( ), ( uint8_t* )" SLAVE", NULL ); - DrawText( LINE4_COL0_TEXT, ( uint8_t* )"Rx OK", ( uint8_t* )" 0", NULL ); - DrawText( LINE5_COL0_TEXT, ( uint8_t* )"Rx KO", ( uint8_t* )" 0", NULL ); - DrawText( LINE6_COL0_TEXT, ( uint8_t* )"Rx PSR", ( uint8_t* )" 0.00", NULL ); - DrawText( LINE7_COL0_TEXT, ( uint8_t* )"Rx PER", ( uint8_t* )" 0.00", NULL ); - DrawText( LINE8_COL0_TEXT, ( uint8_t* )"Last Rssi", ( uint8_t* )" 0", NULL ); - DrawText( LINE9_COL0_TEXT, ( uint8_t* )"Last SNR", ( uint8_t* )" 0", NULL ); - if( Eeprom.EepromData.DemoSettings.Entity == MASTER ) - { - DrawActiveButton( BTN0_BORDER, ( uint8_t* )" MASTER", NULL ); - DrawText( LINE3_COL0_TEXT, NULL, NULL, ( uint8_t* )"MASTER" ); - DrawText( LINE4_COL0_TEXT, NULL, NULL, ( uint8_t* )" 0" ); - DrawText( LINE5_COL0_TEXT, NULL, NULL, ( uint8_t* )" 0" ); - DrawText( LINE6_COL0_TEXT, NULL, NULL, ( uint8_t* )" 0.00" ); - DrawText( LINE7_COL0_TEXT, NULL, NULL, ( uint8_t* )" 0.00" ); - } - else - { - DrawActiveButton( BTN0_BORDER, ( uint8_t* )" SLAVE", NULL ); - } - DrawActiveButton( BTN7_BORDER, ( uint8_t* )" EXIT", NULL ); - DrawActiveButton( BTN8_BORDER, ( uint8_t* )" START", NULL ); - DrawActiveButton( BTN9_BORDER, ( uint8_t* )" SETTINGS", NULL ); - } - CurrentPage = PAGE_PING_PONG; - break; - - case PAGE_PER: - if( CurrentPage == PAGE_PER ) - { - if( Eeprom.EepromData.DemoSettings.HoldDemo == true ) - { - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" START", NULL ); - } - if( Eeprom.EepromData.DemoSettings.Entity == MASTER ) - { - DrawText( LINE4_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoNumSentPacket( ), NULL ); - } - else - { - DrawText( LINE4_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoRxOk( ), NULL ); - DrawText( LINE5_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoRxKo( ), NULL ); - DrawText( LINE6_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoResultPerCent1( Eeprom.EepromData.DemoSettings.CntPacketRxKO + Eeprom.EepromData.DemoSettings.RxTimeOutCount, Eeprom.EepromData.DemoSettings.CntPacketRxOK + Eeprom.EepromData.DemoSettings.CntPacketRxKO + Eeprom.EepromData.DemoSettings.RxTimeOutCount ), NULL ); - DrawText( LINE8_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoRssi( ), NULL ); - DrawText( LINE9_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoSnr( ), NULL ); - } - } - else - { - DrawText( TITLE_TEXT, ( uint8_t* )" PER Demo FHSS", NULL, NULL ); - DrawText( LINE3_COL0_TEXT, ( uint8_t* )"Test Total", ( uint8_t* )GetMenuDemoMaxNumPacket( ), NULL ); - DisplayCurrentRadioParams( PAGE_PER ); - if( Eeprom.EepromData.DemoSettings.Entity == MASTER ) - { - DrawActiveButton( BTN0_BORDER, ( uint8_t* )" MASTER", NULL ); - DrawText( LINE4_COL0_TEXT, ( uint8_t* )"Transmitted", ( uint8_t* )GetMenuDemoNumSentPacket( ), NULL ); - } - else - { - DrawActiveButton( BTN0_BORDER, ( uint8_t* )" SLAVE", NULL ); - DrawText( LINE4_COL0_TEXT, ( uint8_t* )"Rx OK", ( uint8_t* )" 0", NULL ); - DrawText( LINE5_COL0_TEXT, ( uint8_t* )"Rx KO", ( uint8_t* )" 0", NULL ); - DrawText( LINE6_COL0_TEXT, ( uint8_t* )"PER", ( uint8_t* )" 0.00", NULL ); - DrawText( LINE8_COL0_TEXT, ( uint8_t* )"Last Rssi", ( uint8_t* )" 0", NULL ); - DrawText( LINE9_COL0_TEXT, ( uint8_t* )"Last SNR", ( uint8_t* )" 0", NULL ); - } - DrawActiveButton( BTN7_BORDER, ( uint8_t* )" EXIT", NULL ); - DrawActiveButton( BTN8_BORDER, ( uint8_t* )" START", NULL ); - DrawActiveButton( BTN9_BORDER, ( uint8_t* )" SETTINGS", NULL ); - } - CurrentPage = PAGE_PER; - break; - - case PAGE_RANGING_MASTER: - if( CurrentPage == PAGE_RANGING_MASTER ) - { - if( Eeprom.EepromData.DemoSettings.HoldDemo == true ) - { - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" REFRESH", NULL ); - } - // Clear actual distance token - GraphObjectClear( &( MenuObjects[RNG_DIST_CIRCLE] ), true ); - // update scale of circles - for( uint8_t i = SCALE_LINE_COUNT; i > 0; i-- ) - { - sprintf( StringText, "%d", i * ( Eeprom.EepromData.DemoSettings.RngFullScale / SCALE_LINE_COUNT ) ); - DrawText( RNG_DS1_TEXT + i - 1, ( uint8_t* )" ", NULL, NULL ); - DrawText( RNG_DS1_TEXT + i - 1, ( uint8_t* )StringText, NULL, NULL ); - } - uint16_t DistPixel; - // Compute position (pixel) of token - // distance line high is 160px : it's the reference for distance graphical objects (represent full scale) - DistPixel = ( uint16_t )( Eeprom.EepromData.DemoSettings.RngDistance * 160.0 / Eeprom.EepromData.DemoSettings.RngFullScale ); - MenuObjects[RNG_DIST_CIRCLE].FrontColor = WHITE; - // Need to change full scale ? yes if dist > fullscale or if dist < fullscale / SCALE_LINE_COUNT - // fullscale will be updated next time - if( DistPixel > 160 ) - { - DistPixel = 160; - MenuObjects[RNG_DIST_CIRCLE].FrontColor = OBJECT_ERROR; - Eeprom.EepromData.DemoSettings.RngFullScale = ( uint16_t )ceil( 1.2 * ( Eeprom.EepromData.DemoSettings.RngDistance / SCALE_LINE_COUNT ) ) * SCALE_LINE_COUNT; - if( Eeprom.EepromData.DemoSettings.RngFullScale > RANGING_FULLSCALE_MAX ) - { - Eeprom.EepromData.DemoSettings.RngFullScale = RANGING_FULLSCALE_MAX; - } - } - else if( DistPixel < ( 160 / SCALE_LINE_COUNT ) ) - { - Eeprom.EepromData.DemoSettings.RngFullScale = ( uint16_t )ceil( 1.2 * ( Eeprom.EepromData.DemoSettings.RngDistance / SCALE_LINE_COUNT ) ) * SCALE_LINE_COUNT; - if( Eeprom.EepromData.DemoSettings.RngFullScale < RANGING_FULLSCALE_MIN ) - { - Eeprom.EepromData.DemoSettings.RngFullScale = RANGING_FULLSCALE_MIN; - } - } - // Check timeout error - if( Eeprom.EepromData.DemoSettings.RngStatus != RNG_VALID ) - { - MenuObjects[RNG_DIST_CIRCLE].FrontColor = OBJECT_ERROR; - } - switch( Eeprom.EepromData.DemoSettings.RngUnit ) - { - case DEMO_RNG_UNIT_SEL_M: - // Print distance on the top with decimal under 1000 - if( Eeprom.EepromData.DemoSettings.RngDistance >= 1000.0 ) - { - sprintf( StringText, "Range: %5d m", ( uint16_t )Eeprom.EepromData.DemoSettings.RngDistance ); - sprintf( StringText2, "%6d", ( uint16_t )Eeprom.EepromData.DemoSettings.RngRawDistance ); - } - else - { - sprintf( StringText, "Range: %5.1f m", Eeprom.EepromData.DemoSettings.RngDistance ); - sprintf( StringText2, "%6.1f", Eeprom.EepromData.DemoSettings.RngRawDistance ); - } - break; - - case DEMO_RNG_UNIT_SEL_YD: - // Print distance on the top with decimal under 1000 - if( Eeprom.EepromData.DemoSettings.RngDistance >= 1000.0 ) - { - sprintf( StringText, "Range: %5d yd", ( uint16_t )Eeprom.EepromData.DemoSettings.RngDistance ); - sprintf( StringText2, "%6d", ( uint16_t )Eeprom.EepromData.DemoSettings.RngRawDistance ); - } - else - { - sprintf( StringText, "Range: %5.1f yd", Eeprom.EepromData.DemoSettings.RngDistance ); - sprintf( StringText2, "%6.1f", Eeprom.EepromData.DemoSettings.RngRawDistance ); - } - break; - - case DEMO_RNG_UNIT_SEL_MI: - sprintf( StringText, "Range: %5.2f mi", Eeprom.EepromData.DemoSettings.RngDistance ); - sprintf( StringText2, "%6.1f", Eeprom.EepromData.DemoSettings.RngRawDistance ); - break; - } - DrawText( RNG_DIST_TEXT, ( uint8_t* )StringText, NULL, NULL ); - DrawText( LINE5_COL0_TEXT, NULL, ( uint8_t* )StringText2, NULL ); - DrawText( LINE6_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoNumSentPacket( ), NULL ); - DrawText( LINE7_COL0_TEXT, NULL, ( uint8_t* )GetFrequencyError( ), NULL ); - DrawText( LINE8_COL0_TEXT, NULL, ( uint8_t* )GetRngChannelsOk( ), NULL ); - sprintf( StringText, "%6d", Eeprom.EepromData.DemoSettings.CntPacketRxOKSlave ); - DrawText( LINE9_COL0_TEXT, NULL, ( uint8_t* )StringText, NULL ); - - // Draw token at its new position. 270 is the absolute px position (y) of distance 0 - MenuObjects[RNG_DIST_CIRCLE].Ypos = 270 - DistPixel; - GraphObjectDraw( &( MenuObjects[RNG_DIST_CIRCLE] ), NULL, true, false ); + TouchedXYT (&x, &y, &touched); + if ( + (touched != Touched_Prec) || + (x != x_Prec) || + (y != y_Prec) || + (i32_Pulses != Pulses_Prec) + // (Stabilus322699.getPulses() != Pulses_Prec) + ) { + sprintf (StringText, + "Screen Touched: %d %d", touched, i32_Pulses); + DrawText (TITLE_TEXT, (uint8_t*)StringText, NULL , NULL); + + if (touched == true) { + sprintf (StringText, + "x: %d", x); + DrawActiveButton (BTN2_BORDER, (uint8_t*)StringText, NULL); + + sprintf (StringText, + // "Y: %d %f", y, adc_vref.read()); + "Y: %d", y); + DrawActiveButton (BTN3_BORDER, (uint8_t*)StringText, NULL); } - else - { - GraphObject_t clearRect = { NULL, GO_RECTANGLE, 1, 284, 35, 238, \ - 1, BACK_COLOR, BACK_COLOR, true, \ - BACK_COLOR, NULL, false }; - - DrawText( TITLE_TEXT, ( uint8_t* )" Outdoor ranging demo", NULL, NULL ); - DrawActiveButton( BTN0_BORDER, ( uint8_t* )" MASTER", NULL ); - DisplayCurrentRadioParams( PAGE_RANGING_MASTER ); - // Draw lines - GraphObjectDraw( &( MenuObjects[RNG_DS0_LINE] ), NULL, true, false ); - for( uint8_t i = RNG_DS1_LINE; i <= RNG_DS5_LINE; i++ ) - { - GraphObjectDraw( &( MenuObjects[i] ), NULL, true, false ); - } - // Draw around scale of distance - for( uint8_t i = SCALE_LINE_COUNT; i > 0; i-- ) - { - sprintf( StringText, "%d", i * ( Eeprom.EepromData.DemoSettings.RngFullScale / SCALE_LINE_COUNT ) ); - GraphObjectDraw( &( MenuObjects[RNG_DS1_LINE + i - 1] ), NULL, false, false ); - DrawText( RNG_DS1_TEXT + i - 1, ( uint8_t* )StringText, NULL, NULL ); - } - // Clear the area for 2 downstair buttons (7 & 8) - // { Id, Type, Xpos, Ypos, Height, Width, LineWidth, BackColor, \ - FrontColor, DoFill, FillCol, Source, TouchActive } - GraphObjectClear( &clearRect, true ); - GraphObjectDraw( &( MenuObjects[PAGE_BORDER] ), NULL, false, false ); - DrawText( RNG_DIST_TEXT, ( uint8_t* )"Range: -----", NULL, NULL ); - DrawText( LINE5_COL0_TEXT, ( uint8_t* )"Raw [m] :", ( uint8_t* )" -----", NULL ); - DrawText( LINE6_COL0_TEXT, ( uint8_t* )"Packet :", ( uint8_t* )GetMenuDemoNumSentPacket( ), NULL ); - DrawText( LINE7_COL0_TEXT, ( uint8_t* )"FEI [Hz] :", ( uint8_t* )GetFrequencyError( ), NULL ); - DrawText( LINE8_COL0_TEXT, ( uint8_t* )"Channel :", ( uint8_t* )GetRngChannelsOk( ), NULL ); - - DrawActiveButton( BTN7_BORDER, ( uint8_t* )" EXIT", NULL ); - DrawActiveButton( BTN8_BORDER, ( uint8_t* )" START", NULL ); - DrawActiveButton( BTN9_BORDER, ( uint8_t* )" SETTINGS", NULL ); - // draw active rectangle for user touch (like "REFRESH" button) - GraphObjectDraw( &( MenuObjects[RNG_MST_SCR] ), NULL, false, true ); - } - CurrentPage = PAGE_RANGING_MASTER; - break; - - case PAGE_RANGING_SLAVE: - if( CurrentPage == PAGE_RANGING_SLAVE ) - { - if( Eeprom.EepromData.DemoSettings.HoldDemo == true ) - { - ButtonChangeText( BTN8_BORDER, ( uint8_t* )" START", NULL ); - } - DrawText( LINE4_COL0_TEXT, NULL, ( uint8_t* )GetMenuDemoNumSentPacket( ), NULL ); - DrawText( LINE5_COL0_TEXT, NULL, ( uint8_t* )GetFrequencyError( ), NULL ); - DrawText( LINE6_COL0_TEXT, NULL, ( uint8_t* )GetRngChannelsOk( ), NULL ); - sprintf( StringText ," %s", GetRangingAntenna( ) ); - DrawText( LINE7_COL0_TEXT, NULL, ( uint8_t* )StringText, NULL ); - } - else - { - DrawText( TITLE_TEXT, ( uint8_t* )" Outdoor ranging demo", NULL, NULL ); - DisplayCurrentRadioParams( PAGE_RANGING_SLAVE ); - DrawText( LINE4_COL0_TEXT, ( uint8_t* )"Packet :", ( uint8_t* )GetMenuDemoNumSentPacket( ), NULL ); - DrawText( LINE5_COL0_TEXT, ( uint8_t* )"FEI [Hz] :", ( uint8_t* )GetFrequencyError( ), NULL ); - DrawText( LINE6_COL0_TEXT, ( uint8_t* )"Channel :", ( uint8_t* )GetRngChannelsOk( ), NULL ); - sprintf( StringText ," %s", GetRangingAntenna( ) ); - DrawText( LINE7_COL0_TEXT, ( uint8_t* )"Antenna :", ( uint8_t* )StringText, NULL ); - DrawActiveButton( BTN0_BORDER, ( uint8_t* )" SLAVE", NULL ); - DrawActiveButton( BTN7_BORDER, ( uint8_t* )" EXIT", NULL ); - DrawActiveButton( BTN8_BORDER, ( uint8_t* )" START", NULL ); - DrawActiveButton( BTN9_BORDER, ( uint8_t* )" SETTINGS", NULL ); - } - CurrentPage = PAGE_RANGING_SLAVE; - break; - - case PAGE_RADIO_PARAM: - if( CurrentPage == PAGE_RADIO_PARAM ) - { - if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_RANGING ) - { - if( PreviousPage == START_PAGE ) - { - ButtonChangeText( BTN0_BORDER, NULL, ( uint8_t* )GetMenuRadioFrameType( ) ); - } - else - { - RemoveButton( BTN0_BORDER ); - } - DrawActiveButton( BTN6_BORDER, ( uint8_t* )" RANGING SETTINGS", NULL ); - DrawActiveButton( BTN9_BORDER, ( uint8_t* )" BEST SET", NULL ); - } - else - { - DrawActiveButton( BTN0_BORDER, ( uint8_t* )"Mod:", ( uint8_t* )GetMenuRadioFrameType( ) ); - DrawActiveButton( BTN6_BORDER, ( uint8_t* )"Payload:", ( uint8_t* )GetRadioPayloadLength( ) ); - RemoveButton( BTN9_BORDER ); - } - ButtonChangeText( BTN1_BORDER, NULL, ( uint8_t* )GetRadioFrequency( ) ); - ButtonChangeText( BTN2_BORDER, NULL, ( uint8_t* )GetRadioTxPower( ) ); - ButtonChangeText( BTN3_BORDER, NULL, ( uint8_t* )GetRadioModulationParameters1( ) ); - ButtonChangeText( BTN4_BORDER, NULL, ( uint8_t* )GetRadioModulationParameters2( ) ); - ButtonChangeText( BTN5_BORDER, NULL, ( uint8_t* )GetRadioModulationParameters3( ) ); - } - else - { - DrawText( TITLE_TEXT, ( uint8_t* )" Radio Settings", NULL, NULL ); - if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_RANGING ) - { - if( PreviousPage == START_PAGE ) - { - DrawActiveButton( BTN0_BORDER, ( uint8_t* )"Mod:", ( uint8_t* )GetMenuRadioFrameType( ) ); - } - DrawActiveButton( BTN6_BORDER, ( uint8_t* )" RANGING SETTINGS", NULL ); - DrawActiveButton( BTN9_BORDER, ( uint8_t* )" BEST SET", NULL ); - } - else - { - DrawActiveButton( BTN0_BORDER, ( uint8_t* )"Mod:", ( uint8_t* )GetMenuRadioFrameType( ) ); - DrawActiveButton( BTN6_BORDER, ( uint8_t* )"Payload:", ( uint8_t* )GetRadioPayloadLength( ) ); - } - DrawActiveButton( BTN1_BORDER, ( uint8_t* )"Freq:", ( uint8_t* )GetRadioFrequency( ) ); - DrawActiveButton( BTN2_BORDER, ( uint8_t* )"Tx Pow:", ( uint8_t* )GetRadioTxPower( ) ); - DrawActiveButton( BTN3_BORDER, ( uint8_t* )"Param 1:", ( uint8_t* )GetRadioModulationParameters1( ) ); - DrawActiveButton( BTN4_BORDER, ( uint8_t* )"Param 2:", ( uint8_t* )GetRadioModulationParameters2( ) ); - DrawActiveButton( BTN5_BORDER, ( uint8_t* )"Param 3:", ( uint8_t* )GetRadioModulationParameters3( ) ); - DrawActiveButton( BTN7_BORDER, ( uint8_t* )" CANCEL", NULL ); - DrawActiveButton( BTN8_BORDER, ( uint8_t* )" OK & SAVE", NULL ); - CurrentPage = PAGE_RADIO_PARAM; - } - break; - - case PAGE_RANGING_PARAM: - if( CurrentPage != PAGE_RANGING_PARAM ) - { - DrawText( TITLE_TEXT, ( uint8_t* )" Settings : Ranging", NULL, NULL ); - - DrawActiveButton( BTN1_BORDER, ( uint8_t* )"Request:", ( uint8_t* )GetRangingRequestCount( ) ); - DrawActiveButton( BTN2_BORDER, ( uint8_t* )"Address:", ( uint8_t* )GetRangingAddress( ) ); - DrawActiveButton( BTN3_BORDER, ( uint8_t* )"Antenna:", ( uint8_t* )GetRangingAntenna( ) ); - DrawActiveButton( BTN4_BORDER, ( uint8_t* )"Unit:", ( uint8_t* )GetRangingUnit( ) ); - DrawActiveButton( BTN7_BORDER, ( uint8_t* )" CANCEL", NULL ); - DrawActiveButton( BTN8_BORDER, ( uint8_t* )" OK & SAVE", NULL ); + else { + DrawActiveButton (BTN2_BORDER, (uint8_t*) "No Touch ...", NULL); + DrawActiveButton (BTN3_BORDER, (uint8_t*) "No Touch ...", NULL); } - CurrentPage = PAGE_RANGING_PARAM; - break; - - case PAGE_RADIO_PARAM_FREQ: - if( CurrentPage != PAGE_RADIO_PARAM_FREQ ) - { - DrawText( TITLE_TEXT, ( uint8_t* )" Radio Settings : Freq", NULL, NULL ); - DrawActiveButton( BTN0_BORDER, ( uint8_t* )" -", NULL ); - DrawActiveButton( BTN1_BORDER, ( uint8_t* )"Step:", ( uint8_t* )GetRadioFreqBase( ) ); - // do not draw boarder for indicate actual frequency (it is not a button) - ButtonChangeText( BTN2_BORDER, ( uint8_t* )"Freq:", ( uint8_t* )GetRadioFrequency( ) ); - DrawActiveButton( BTN3_BORDER, ( uint8_t* )"Preset1:", ( uint8_t* )GetRadioFreqBasePS1( ) ); - DrawActiveButton( BTN4_BORDER, ( uint8_t* )"Preset2:", ( uint8_t* )GetRadioFreqBasePS2( ) ); - DrawActiveButton( BTN5_BORDER, ( uint8_t* )"Preset3:", ( uint8_t* )GetRadioFreqBasePS3( ) ); - DrawActiveButton( BTN7_BORDER, ( uint8_t* )" CANCEL", NULL ); - DrawActiveButton( BTN8_BORDER, ( uint8_t* )" OK", NULL ); - DrawActiveButton( BTN9_BORDER, ( uint8_t* )" +", NULL ); - } - CurrentPage = PAGE_RADIO_PARAM_FREQ; - break; - - case PAGE_UTILITIES: - if( CurrentPage == PAGE_UTILITIES ) - { - DrawText( LINE1_TEXT, ( uint8_t* )GetGpsTime( ), NULL, NULL ); - DrawText( LINE2_TEXT, ( uint8_t* )GetGpsPos( ), NULL, NULL ); - DrawText( LINE3_TEXT, ( uint8_t* )GetProximityValue( ), NULL, NULL ); - } - else - { - char version_holder[50]; - sprintf(&version_holder[0], "Version: %s (%s)", FIRMWARE_VERSION, FIRMWARE_DATE); - DrawText( TITLE_TEXT, ( uint8_t* )" Utilities", NULL, NULL ); - // FIRMWARE_VERSION is defined in DemoApplication.h - DrawText( LINE0_TEXT, ( uint8_t* )version_holder, NULL, NULL ); - DrawText( LINE1_TEXT, ( uint8_t* )GetGpsTime( ), NULL, NULL ); - DrawText( LINE2_TEXT, ( uint8_t* )GetGpsPos( ), NULL, NULL ); - DrawText( LINE3_TEXT, ( uint8_t* )GetProximityValue( ), NULL, NULL ); - DrawActiveButton( BTN0_BORDER, ( uint8_t* )"Fact. Reset", NULL ); - DrawActiveButton( BTN4_BORDER, ( uint8_t* )"PA Mode:", ( uint8_t* )GetMenuDemoRadioPowerMode( ) ); - DrawActiveButton( BTN5_BORDER, ( uint8_t* )"Packets:", ( uint8_t* )GetMenuDemoMaxNumPacket( ) ); - DrawActiveButton( BTN6_BORDER, ( uint8_t* )"Antenna:", ( uint8_t* )GetAntennaSetting( ) ); - DrawActiveButton( BTN7_BORDER, ( uint8_t* )" CANCEL", NULL ); - DrawActiveButton( BTN8_BORDER, ( uint8_t* )" OK & SAVE", NULL ); - } - CurrentPage = PAGE_UTILITIES; - break; - - case PAGE_RADIO_TEST: - DrawText( TITLE_TEXT, ( uint8_t* )" Radio Test Modes", NULL, NULL ); - DrawActiveButton( BTN1_BORDER, ( uint8_t* )" Sleep Mode", NULL ); - DrawActiveButton( BTN2_BORDER, ( uint8_t* )" Standby RC Mode", NULL ); - DrawActiveButton( BTN3_BORDER, ( uint8_t* )" Standby XOSC Mode", NULL ); - DrawActiveButton( BTN4_BORDER, ( uint8_t* )" Set Tx CW", NULL ); - DrawActiveButton( BTN5_BORDER, ( uint8_t* )" Set Cont. Modulation", NULL ); - DrawActiveButton( BTN7_BORDER, ( uint8_t* )" BACK", NULL ); - CurrentPage = PAGE_RADIO_TEST; - break; - - case PAGE_SLEEP_MODE: - if( CurrentPage != PAGE_UTILITIES ) - { - DrawText( TITLE_TEXT, ( uint8_t* )" Sleep Mode", NULL, NULL ); - DisplayCurrentRadioParams( PAGE_SLEEP_MODE ); - DrawActiveButton( BTN7_BORDER, ( uint8_t* )" EXIT", NULL ); - DrawActiveButton( BTN8_BORDER, ( uint8_t* )" START", NULL ); - DrawActiveButton( BTN9_BORDER, ( uint8_t* )" SETTINGS", NULL ); - CurrentPage = PAGE_SLEEP_MODE; - } - break; - - case PAGE_STBY_RC_MODE: - if( CurrentPage != PAGE_STBY_RC_MODE ) - { - DrawText( TITLE_TEXT, ( uint8_t* )" Standby RC Mode", NULL, NULL ); - DisplayCurrentRadioParams( PAGE_STBY_RC_MODE ); - DrawActiveButton( BTN7_BORDER, ( uint8_t* )" EXIT", NULL ); - DrawActiveButton( BTN8_BORDER, ( uint8_t* )" START", NULL ); - DrawActiveButton( BTN9_BORDER, ( uint8_t* )" SETTINGS", NULL ); - CurrentPage = PAGE_STBY_RC_MODE; - } - break; - - case PAGE_STBY_XOSC_MODE: - if( CurrentPage != PAGE_STBY_XOSC_MODE ) - { - DrawText( TITLE_TEXT, ( uint8_t* )" Standby XOSC Mode", NULL, NULL ); - DisplayCurrentRadioParams( PAGE_STBY_XOSC_MODE ); - DrawActiveButton( BTN7_BORDER, ( uint8_t* )" EXIT", NULL ); - DrawActiveButton( BTN8_BORDER, ( uint8_t* )" START", NULL ); - DrawActiveButton( BTN9_BORDER, ( uint8_t* )" SETTINGS", NULL ); - CurrentPage = PAGE_STBY_XOSC_MODE; - } - break; - - case PAGE_TX_CW: - if( CurrentPage != PAGE_TX_CW ) - { - DrawText( TITLE_TEXT, ( uint8_t* )" Set Tx CW", NULL, NULL ); - DisplayCurrentRadioParams( PAGE_TX_CW ); - DrawActiveButton( BTN7_BORDER, ( uint8_t* )" EXIT", NULL ); - DrawActiveButton( BTN8_BORDER, ( uint8_t* )" START", NULL ); - DrawActiveButton( BTN9_BORDER, ( uint8_t* )" SETTINGS", NULL ); - CurrentPage = PAGE_TX_CW; - } - break; - - case PAGE_CONT_MODULATION: - if( CurrentPage != PAGE_CONT_MODULATION ) - { - DrawText( TITLE_TEXT, ( uint8_t* )" Set Cont. Modulation", NULL, NULL ); - DisplayCurrentRadioParams( PAGE_CONT_MODULATION ); - DrawActiveButton( BTN7_BORDER, ( uint8_t* )" EXIT", NULL ); - DrawActiveButton( BTN8_BORDER, ( uint8_t* )" START", NULL ); - DrawActiveButton( BTN9_BORDER, ( uint8_t* )" SETTINGS", NULL ); - CurrentPage = PAGE_CONT_MODULATION; - } - break; - - default: - break; - } -} -*/ - -/* -void DisplayCurrentRadioParams( uint8_t page ) -{ - switch( page ) - { - case PAGE_SLEEP_MODE: - case PAGE_STBY_RC_MODE: - case PAGE_STBY_XOSC_MODE: - case PAGE_TX_CW: - // Do display different without packet settings (no modulation here) - // 2 + (9) + 4 + (7) + 2 + (4) = 28 (=<28 : ok) - sprintf( StringText ,"f:%s, P:%s, %s", GetRadioFrequencyGHz( ), \ - GetRadioTxPower( ), GetAntennaSetting( ) ); - DrawText( LINE0_TEXT, ( uint8_t* )StringText, NULL, NULL ); - sprintf( StringText ,"Radio Power Mode: %s", ( uint8_t* )GetMenuDemoRadioPowerMode( ) ); - DrawText( LINE1_TEXT, ( uint8_t* )StringText, NULL, NULL ); - sprintf( StringText ,"Press START to launch test" ); - DrawText( LINE3_TEXT, ( uint8_t* )StringText, NULL, NULL ); - break; + + Touched_Prec = touched; + x_Prec = x; + y_Prec = y; + // + Pulses_Prec = i32_Pulses; + } - case PAGE_CONT_MODULATION: - // 2 + (9) + 4 + (7) + 2 + (4) = 28 (=<28 : ok) - sprintf( StringText ,"f:%s, P:%s, %s", GetRadioFrequencyGHz( ), \ - GetRadioTxPower( ), GetAntennaSetting( ) ); - DrawText( LINE0_TEXT, ( uint8_t* )StringText, NULL, NULL ); - // (7) + 2 + (19) = 28 (=<28 : ok) - sprintf( StringText ,"%s: %s", GetMenuRadioFrameType( ), \ - GetRadioModulationParameters1( ) ); - DrawText( LINE1_TEXT, ( uint8_t* )StringText, NULL, NULL ); - // (3) + 2 + (10) + 2 + (8) = 25 (=<28 : ok) - sprintf( StringText ,"%s, %s, %s", GetRadioModulationParameters2( ), \ - GetRadioModulationParameters3( ), - ( uint8_t* )GetMenuDemoRadioPowerMode( ) ); - DrawText( LINE2_TEXT, ( uint8_t* )StringText, NULL, NULL ); - sprintf( StringText ,"Press START to launch test" ); - DrawText( LINE4_TEXT, ( uint8_t* )StringText, NULL, NULL ); - break; - - case PAGE_PING_PONG: // standart display - case PAGE_PER: - // 2 + (9) + 4 + (7) + 2 + (4) = 28 (=<28 : ok) - sprintf( StringText ,"f:%s, P:%s, %s", GetRadioFrequencyGHz( ), \ - GetRadioTxPower( ), GetAntennaSetting( ) ); - DrawText( LINE0_TEXT, ( uint8_t* )StringText, NULL, NULL ); - // (7) + 2 + (19) = 28 (=<28 : ok) - sprintf( StringText ,"%s: %s", GetMenuRadioFrameType( ), \ - GetRadioModulationParameters1( ) ); - DrawText( LINE1_TEXT, ( uint8_t* )StringText, NULL, NULL ); - // 3 + (3) + 2 + (10) + 2 + (8) = 28 (=<28 : ok) - sprintf( StringText ,"PL:%s, %s, %s", GetRadioPayloadLength( ), \ - GetRadioModulationParameters2( ), \ - GetRadioModulationParameters3( ) ); - DrawText( LINE2_TEXT, ( uint8_t* )StringText, NULL, NULL ); - break; - - case PAGE_RANGING_SLAVE: - // 2 + (9) + 4 + (7) = 22 (=<28 : ok) - sprintf( StringText ,"f:%s, P:%s", GetRadioFrequencyGHz( ), \ - GetRadioTxPower( ) ); - DrawText( LINE0_TEXT, ( uint8_t* )StringText, NULL, NULL ); - // (7) + 2 + (19) = 28 (=<28 : ok) - sprintf( StringText ,"%s: %s", GetMenuRadioFrameType( ), \ - GetRadioModulationParameters1( ) ); - DrawText( LINE1_TEXT, ( uint8_t* )StringText, NULL, NULL ); - // (10) + 2 + (8) = 20 (=<28 : ok) - sprintf( StringText ,"%s", GetRadioModulationParameters2( ) ); - DrawText( LINE2_TEXT, ( uint8_t* )StringText, NULL, NULL ); - break; - - case PAGE_RANGING_MASTER: - sprintf( StringText ,"f:%s", GetRadioFrequencyGHz( ) ); - DrawText( LINE1_TEXT, ( uint8_t* )StringText, NULL, NULL ); - DrawText( LINE2_COL0_TEXT, ( uint8_t* )"Antenna", ( uint8_t* )GetRangingAntenna( ), NULL ); - sprintf( StringText ,"%s", GetRadioTxPower( ) ); - MenuObjects[LINE3_COL1_TEXT].FrontColor = TEXT_COLOR; - DrawText( LINE3_COL0_TEXT, ( uint8_t* )"Tx Power", ( uint8_t* )StringText, NULL ); - sprintf( StringText ,"%s", GetRadioModulationParameters2( ) ); - DrawText( LINE4_COL0_TEXT, ( uint8_t* )StringText, NULL, NULL ); - sprintf( StringText ,"%s", GetRadioModulationParameters1( ) ); - MenuObjects[LINE4_COL1_TEXT].FrontColor = TEXT_COLOR; - DrawText( LINE4_COL1_TEXT, ( uint8_t* )StringText, NULL, NULL ); - MenuObjects[LINE3_COL1_TEXT].FrontColor = TEXT_VALUE; - MenuObjects[LINE4_COL1_TEXT].FrontColor = TEXT_VALUE; - break; - } -} -*/ - -/* -char* GetMenuRadioFrameType( void ) -{ - switch( Eeprom.EepromData.DemoSettings.ModulationType ) - { - case PACKET_TYPE_FLRC: return ( char* )" FLRC"; - case PACKET_TYPE_RANGING: return ( char* )"RANGING"; - case PACKET_TYPE_GFSK: return ( char* )" GFSK"; - case PACKET_TYPE_BLE: return ( char* )" BLE"; - case PACKET_TYPE_LORA: - default: return ( char* )" LORA"; - } -} -*/ - -/* -char* GetRadioModulationParameters1( void ) -{ - if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_FLRC ) - { - switch( Eeprom.EepromData.DemoSettings.ModulationParam1 ) - { - case FLRC_BR_1_300_BW_1_2: return ( char* )"1.3 Mbps/BW 1.2 MHz"; - case FLRC_BR_1_040_BW_1_2: return ( char* )"1.0 Mbps/BW 1.2 MHz"; - case FLRC_BR_0_650_BW_0_6: return ( char* )"650 kbps/BW 600 kHz"; - case FLRC_BR_0_520_BW_0_6: return ( char* )"520 kbps/BW 600 kHz"; - case FLRC_BR_0_325_BW_0_3: return ( char* )"325 kbps/BW 300 kHz"; - case FLRC_BR_0_260_BW_0_3: return ( char* )"260 kbps/BW 300 kHz"; - default: return ( char* )"X"; - } - } - else if( ( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_GFSK ) || \ - ( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_BLE ) ) - { - switch( Eeprom.EepromData.DemoSettings.ModulationParam1 ) - { - case GFSK_BLE_BR_2_000_BW_2_4: return ( char* )"2.0 Mbps/BW 2.4 MHz"; - case GFSK_BLE_BR_1_600_BW_2_4: return ( char* )"1.6 Mbps/BW 2.4 MHz"; - case GFSK_BLE_BR_1_000_BW_2_4: return ( char* )"1.0 Mbps/BW 2.4 MHz"; - case GFSK_BLE_BR_1_000_BW_1_2: return ( char* )"1.0 Mbps/BW 1.2 MHz"; - case GFSK_BLE_BR_0_800_BW_2_4: return ( char* )"800 kbps/BW 2.4 MHz"; - case GFSK_BLE_BR_0_800_BW_1_2: return ( char* )"800 kbps/BW 1.2 MHz"; - case GFSK_BLE_BR_0_500_BW_1_2: return ( char* )"500 kbps/BW 1.2 MHz"; - case GFSK_BLE_BR_0_500_BW_0_6: return ( char* )"500 kbps/BW 600 kHz"; - case GFSK_BLE_BR_0_400_BW_1_2: return ( char* )"400 kbps/BW 1.2 MHz"; - case GFSK_BLE_BR_0_400_BW_0_6: return ( char* )"400 kbps/BW 600 kHz"; - case GFSK_BLE_BR_0_250_BW_0_6: return ( char* )"250 kbps/BW 600 kHz"; - case GFSK_BLE_BR_0_250_BW_0_3: return ( char* )"250 kbps/BW 300 kHz"; - case GFSK_BLE_BR_0_125_BW_0_3: return ( char* )"125 kbps/BW 300 kHz"; - default: return ( char* )"X"; - } - } - else if( ( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_LORA ) || \ - ( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_RANGING ) ) - { - switch( Eeprom.EepromData.DemoSettings.ModulationParam1 ) - { - case LORA_SF5: return ( char* )"SF5"; - case LORA_SF6: return ( char* )"SF6"; - case LORA_SF7: return ( char* )"SF7"; - case LORA_SF8: return ( char* )"SF8"; - case LORA_SF9: return ( char* )"SF9"; - case LORA_SF10: return ( char* )"SF10"; - case LORA_SF11: return ( char* )"SF11"; - case LORA_SF12: return ( char* )"SF12"; - default: return ( char* )"X"; + if (ms_0001 != ms_0001_prec) { + sprintf (StringText, + // "adc_temp: %f", (adc_temp.read()* 100)); + "PreviousStep_ms: %d", ms_0001); + DrawActiveButton (BTN4_BORDER, (uint8_t*)StringText, NULL); + ms_0001_prec = ms_0001; } - } - else - { - return ( char* )""; - } -} -*/ - -/* -char* GetRadioModulationParameters2( void ) -{ - if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_FLRC ) - { - switch( Eeprom.EepromData.DemoSettings.ModulationParam2 ) - { - case FLRC_CR_1_2: return ( char* )"CR 1/2"; - case FLRC_CR_3_4: return ( char* )"CR 3/4"; - case FLRC_CR_1_0: return ( char* )"CR 1"; - default: return ( char* )"X"; - } - } - else if( ( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_GFSK ) || \ - ( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_BLE ) ) - { - switch( Eeprom.EepromData.DemoSettings.ModulationParam2 ) - { - case GFSK_BLE_MOD_IND_0_35: return ( char* )"Mod.i 0.35"; - case GFSK_BLE_MOD_IND_0_50: return ( char* )"Mod.i 0.5"; - case GFSK_BLE_MOD_IND_0_75: return ( char* )"Mod.i 0.75"; - case GFSK_BLE_MOD_IND_1_00: return ( char* )"Mod.i 1"; - case GFSK_BLE_MOD_IND_1_25: return ( char* )"Mod.i 1.25"; - case GFSK_BLE_MOD_IND_1_50: return ( char* )"Mod.i 1.5"; - case GFSK_BLE_MOD_IND_1_75: return ( char* )"Mod.i 1.75"; - case GFSK_BLE_MOD_IND_2_00: return ( char* )"Mod.i 2"; - case GFSK_BLE_MOD_IND_2_25: return ( char* )"Mod.i 2.25"; - case GFSK_BLE_MOD_IND_2_50: return ( char* )"Mod.i 2.50"; - case GFSK_BLE_MOD_IND_2_75: return ( char* )"Mod.i 2.75"; - case GFSK_BLE_MOD_IND_3_00: return ( char* )"Mod.i 3"; - case GFSK_BLE_MOD_IND_3_25: return ( char* )"Mod.i 3.25"; - case GFSK_BLE_MOD_IND_3_50: return ( char* )"Mod.i 3.5"; - case GFSK_BLE_MOD_IND_3_75: return ( char* )"Mod.i 3.75"; - case GFSK_BLE_MOD_IND_4_00: return ( char* )"Mod.i 4"; - default: return ( char* )"X"; - } - } - else if( ( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_LORA ) || \ - ( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_RANGING ) ) - { - switch( Eeprom.EepromData.DemoSettings.ModulationParam2 ) - { - case LORA_BW_0200: return ( char* )"BW 200 kHz"; - case LORA_BW_0400: return ( char* )"BW 400 kHz"; - case LORA_BW_0800: return ( char* )"BW 800 kHz"; - case LORA_BW_1600: return ( char* )"BW 1.6 MHz"; - default: return ( char* )"X"; + + if (ms_0002 != ms_0002_prec) { + sprintf (StringText, + // "adc_vref: %f", (adc_vref.read())); + "StepSampled_ms : %d", ms_0002); + DrawActiveButton (BTN5_BORDER, (uint8_t*)StringText, NULL); + ms_0002_prec = ms_0002; } - } - else - { - return ( char* )""; - } -} -*/ - -/* -char* GetRadioModulationParameters3( void ) -{ - if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_FLRC ) - { - switch( Eeprom.EepromData.DemoSettings.ModulationParam3 ) - { - case RADIO_MOD_SHAPING_BT_OFF: return ( char* )"BT OFF"; - case RADIO_MOD_SHAPING_BT_1_0: return ( char* )"BT 1"; - case RADIO_MOD_SHAPING_BT_0_5: return ( char* )"BT 0.5"; - default: return ( char* )"X"; - } - } - else if( ( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_GFSK ) || \ - ( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_BLE ) ) - { - switch( Eeprom.EepromData.DemoSettings.ModulationParam3 ) - { - case RADIO_MOD_SHAPING_BT_OFF: return ( char* )"BT OFF"; - case RADIO_MOD_SHAPING_BT_1_0: return ( char* )"BT 1"; - case RADIO_MOD_SHAPING_BT_0_5: return ( char* )"BT 0.5"; - default: return ( char* )"X"; - } - } - else if( ( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_LORA ) || \ - ( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_RANGING ) ) - { - switch( Eeprom.EepromData.DemoSettings.ModulationParam3 ) - { - case LORA_CR_4_5: return ( char* )"CR 4/5"; - case LORA_CR_4_6: return ( char* )"CR 4/6"; - case LORA_CR_4_7: return ( char* )"CR 4/7"; - case LORA_CR_4_8: return ( char* )"CR 4/8"; - case LORA_CR_LI_4_5: return ( char* )"CRLI 4/5"; - case LORA_CR_LI_4_6: return ( char* )"CRLI 4/6"; - case LORA_CR_LI_4_7: return ( char* )"CRLI 4/7"; - default: return ( char* )"X"; + + if (ms_0003 != ms_0003_prec) { + sprintf (StringText, + // "adc_vbat: %f", (adc_vbat.read())); + "PassedActual_ms: %d", ms_0003); + DrawActiveButton (BTN6_BORDER, (uint8_t*)StringText, NULL); + ms_0003_prec = ms_0003; } - } - else - { - return ( char* )""; - } -} -*/ - -/* -char* GetRadioFrequency( void ) -{ - sprintf( StringText2, "%lu Hz", \ - ( unsigned long )Eeprom.EepromData.DemoSettings.Frequency ); - return StringText2; -} - -void UpdateRadioFrequency( unsigned long freq ) -{ - sprintf( StringText ,"f:%1d.%03d GHz, P:%s, %s", freq / 1000000000, ( freq / 1000000 ) % 1000, GetRadioTxPower( ), GetAntennaSetting( ) ); - DrawText( LINE0_TEXT, ( uint8_t* )StringText, NULL, NULL ); -} - -char* GetRadioFrequencyGHz( void ) -{ - // quicker than using a float (which is not optimized in MBED) - sprintf( StringText3, "%1d.%03d GHz", \ - Eeprom.EepromData.DemoSettings.Frequency / 1000000000, \ - ( Eeprom.EepromData.DemoSettings.Frequency / 1000000 ) % 1000 ); - return StringText3; -} - -char* GetRadioFreqBase( void ) -{ - switch( CurrentFreqBase ) - { - case FB1: return ( char* )"1 Hz"; - case FB10: return ( char* )"10 Hz"; - case FB100: return ( char* )"100 Hz"; - case FB1K: return ( char* )"1 kHz"; - case FB10K: return ( char* )"10 kHz"; - case FB100K: return ( char* )"100 kHz"; - case FB1M: return ( char* )"1 MHz"; - case FB10M: return ( char* )"10 MHz"; - default: return ( char* )"X"; - } -} -char* GetRadioFreqBasePS1( void ) -{ - sprintf( StringText, "%lu Hz", DEMO_CENTRAL_FREQ_PRESET1 ); - return StringText; -} - -char* GetRadioFreqBasePS2( void ) -{ - sprintf( StringText, "%lu Hz", DEMO_CENTRAL_FREQ_PRESET2 ); - return StringText; -} - -char* GetRadioFreqBasePS3( void ) -{ - sprintf( StringText, "%lu Hz", DEMO_CENTRAL_FREQ_PRESET3 ); - return StringText; -} - -char* GetRadioTxPower( void ) -{ - sprintf( StringText2, "%d dBm", Eeprom.EepromData.DemoSettings.TxPower ); - return StringText2; -} - -char* GetRadioPayloadLength( void ) -{ - if( Eeprom.EepromData.DemoSettings.ModulationType == PACKET_TYPE_LORA ) - { - sprintf( StringText2, "%d", Eeprom.EepromData.DemoSettings.PacketParam3 ); - } - else // PACKET_TYPE_GFSK, PACKET_TYPE_FLRC - { - sprintf( StringText2, "%d", Eeprom.EepromData.DemoSettings.PacketParam5 ); - } - return StringText2; -} - -char* GetMenuDemoMaxNumPacket( void ) -{ - if( Eeprom.EepromData.DemoSettings.MaxNumPacket == 0 ) - { - return ( char* )"Infinite"; - } - else - { - sprintf( StringText, "%6d", Eeprom.EepromData.DemoSettings.MaxNumPacket ); - } - return StringText; -} - -char* GetMenuDemoNumSentPacket( void ) -{ - sprintf( StringText2, "%6d", Eeprom.EepromData.DemoSettings.CntPacketTx ); - return StringText2; -} - -char* GetMenuDemoRxOk( void ) -{ - sprintf( StringText2, "%6lu", \ - ( unsigned long )( Eeprom.EepromData.DemoSettings.CntPacketRxOK ) ); - return StringText2; -} - -char* GetMenuDemoRxKo( void ) -{ - sprintf( StringText2, "%6lu", \ - ( unsigned long )( Eeprom.EepromData.DemoSettings.CntPacketRxKO + \ - Eeprom.EepromData.DemoSettings.RxTimeOutCount ) ); - return StringText2; -} - -char* GetMenuDemoRxOkSlave( void ) -{ - sprintf( StringText3, "%6lu", \ - ( unsigned long )( Eeprom.EepromData.DemoSettings.CntPacketRxOKSlave ) ); - return StringText3; -} - -char* GetMenuDemoResultPerCent1( uint32_t value, uint32_t reference ) -{ - // quicker than using a float (which is not optimized in MBED) - sprintf( StringText2, "%3d.%02d", \ - ( ( value * 10000 ) / reference ) / 100, \ - ( ( value * 10000 ) / reference ) % 100 ); - return StringText2; -} - -char* GetMenuDemoResultPerCent2( uint32_t value, uint32_t reference ) -{ - // quicker than using a float (which is not optimized in MBED) - sprintf( StringText3, "%3d.%02d", \ - ( ( value * 10000 ) / reference ) / 100, \ - ( ( value * 10000 ) / reference ) % 100 ); - return StringText3; -} - -char* GetMenuDemoRxKoSlave( void ) -{ - sprintf( StringText3, "%6lu", \ - ( unsigned long )( Eeprom.EepromData.DemoSettings.CntPacketRxKOSlave ) ); - return StringText3; -} - -char* GetMenuDemoRssi( void ) -{ - sprintf( StringText2, "%6d", Eeprom.EepromData.DemoSettings.RssiValue ); - return StringText2; -} - -char* GetMenuDemoSnr( void ) -{ - if( Eeprom.EepromData.DemoSettings.SnrValue >= 0 ) - { - sprintf( StringText2, " /" ); - } - else - { - sprintf( StringText2, "%6d", Eeprom.EepromData.DemoSettings.SnrValue ); - } - return StringText2; -} - -char* GetAntennaSetting( void ) -{ - if( Eeprom.EepromData.DemoSettings.AntennaSwitch == 0 ) - { - return ( char* )"ANT1"; - } - else - { - return ( char* )"ANT0"; - } -} - -char* GetTotalPackets( void ) -{ - if( Eeprom.EepromData.DemoSettings.MaxNumPacket == 0 ) - { - return ( char* )"Total: Inf."; + PBPushed = userButton; + if (PBPushed != PBPushed_prec) { + sprintf (StringText, + "PB Released: %d", PBPushed); + DrawActiveButton (BTN7_BORDER, (uint8_t*)StringText, NULL); + PBPushed_prec = PBPushed; + } + // +// StabilusMainPage (graphObjectTouched, ms_0001, ms_0002, ms_0003, i32_Pulses); + InProgress = false; } - else - { - sprintf( StringText, "Total: %5lu", \ - ( unsigned long )( Eeprom.EepromData.DemoSettings.MaxNumPacket ) ); - return StringText; - } -} - -#if defined(HAS_GPS_SENSOR) -char* GetGpsTime( void ) -{ - thisGps = Max7GpsgetData( ); - if( ( thisGps->Position.Fixed ) && ( thisGps->Time.Updated ) ) - { - sprintf( StringText, "GPS: %s.%s.%s %s:%s:%s", thisGps->Time.Year, \ - thisGps->Time.Month, \ - thisGps->Time.Day, \ - thisGps->Time.Hour, \ - thisGps->Time.Minute, \ - thisGps->Time.Second ); - thisGps->Time.Updated = false; - return StringText; - } - else - { - return ( char* )"GPS: Satellites searching.."; - } -} - -char* GetGpsPos( void ) -{ - thisGps = Max7GpsgetData( ); - if( thisGps->Position.Fixed ) - { - sprintf( StringText,"%s, %s", thisGps->Position.Lat, \ - thisGps->Position.Long ); - return StringText; - } - else - { - return ( char* )"Pos: Satellites searching.."; - } -} -#else -char* GetGpsTime( void ) -{ - return ( char* )""; -} - -char* GetGpsPos( void ) -{ - return ( char* )"GPS: Not supported"; -} -#endif - -#if defined(HAS_PROXIMITY_SENSOR) -char* GetProximityValue( void ) -{ - sprintf( StringText,"Proximity : %06d, %06d", \ - SX9306proximityGetReadValue( 1 ), \ - SX9306proximityGetReadValue( 0 ) ); // Left then right - return StringText; -} -#else -char* GetProximityValue( void ) -{ - return ( char * )"Proximity: Not supported"; -} -#endif - -char* GetMenuDemoRadioPowerMode( void ) -{ - if( Eeprom.EepromData.DemoSettings.RadioPowerMode == USE_LDO ) - { - return ( char* )" LDO"; - } - else - { - return ( char* )" DCDC"; - } -} - -char* GetFrequencyError( void ) -{ - sprintf( StringText2, "%6d", ( int32_t )Eeprom.EepromData.DemoSettings.RngFei ); - return StringText2; -} - -char* GetRngChannelsOk( void ) -{ - if( Eeprom.EepromData.DemoSettings.Entity == SLAVE ) - { - Eeprom.EepromData.DemoSettings.CntPacketRxOK /= 2; - } - sprintf( StringText2, "%03d/%03d", Eeprom.EepromData.DemoSettings.CntPacketRxOK, Eeprom.EepromData.DemoSettings.RngRequestCount ); - return StringText2; -} - -char* GetRangingRequestCount( void ) -{ - sprintf( StringText2, "%d", Eeprom.EepromData.DemoSettings.RngRequestCount ); - return StringText2; -} - -char* GetRangingAddress( void ) -{ - sprintf( StringText2, "0x%08x", Eeprom.EepromData.DemoSettings.RngAddress ); - return StringText2; -} - -char* GetRangingAntenna( void ) -{ - switch( Eeprom.EepromData.DemoSettings.RngAntenna ) - { - case DEMO_RNG_ANT_1: return ( char* )"ANT1"; - case DEMO_RNG_ANT_0: return ( char* )"ANT0"; - case DEMO_RNG_ANT_BOTH: return ( char* )"BOTH"; - default: return ( char* )"X"; - } -} - -char* GetRangingUnit( void ) -{ - switch( Eeprom.EepromData.DemoSettings.RngUnit ) - { - case DEMO_RNG_UNIT_SEL_M: return ( char* )"Meter"; - case DEMO_RNG_UNIT_SEL_YD: return ( char* )"Yard"; - case DEMO_RNG_UNIT_SEL_MI: return ( char* )"Mile"; - default: return ( char* )"X"; - } -} -*/ - -void CheckScreen( void ) -{ - CheckScreenFlag = true; -} - -void CheckRefresh( void ) -{ - PageRefresh = true; -} - -void DebouncedScreen (void ) -{ - ScreenBeenDebounced = false; - DebouncedScreenTouch.detach( ); } /*! @@ -2539,63 +372,47 @@ * \param [in] *text1 Text to draw as label * \param [in] *text2 Text to draw as value */ -void DrawActiveButton( uint8_t buttonId, uint8_t* text1, uint8_t* text2 ) -{ +void DrawActiveButton( uint8_t buttonId, uint8_t* text1, uint8_t* text2 ){ GraphObjectDraw( &( MenuObjects[buttonId] ), NULL, NULL, true ); - if( text2 == NULL ) - { - if( text1 != NULL ) - { + if( text2 == NULL ) { + if( text1 != NULL ) { GraphObjectDraw( &( MenuObjects[buttonId + 1] ), text1, NULL, false ); } } - else - { - if( text1 != NULL ) - { + else { + if( text1 != NULL ) { GraphObjectDraw( &( MenuObjects[buttonId + 2] ), text1, NULL, false ); } GraphObjectDraw( &( MenuObjects[buttonId + 3] ), text2, NULL, false ); } } -void ButtonChangeText( uint8_t buttonId, uint8_t* text1, uint8_t* text2 ) -{ - if( text2 == NULL ) - { - if( text1 != NULL ) - { +void ButtonChangeText( uint8_t buttonId, uint8_t* text1, uint8_t* text2 ){ + if( text2 == NULL ) { + if( text1 != NULL ) { GraphObjectDraw( &( MenuObjects[buttonId + 1] ), text1, NULL, false ); } } - else - { - if( text1 != NULL ) - { + else { + if( text1 != NULL ) { GraphObjectDraw( &( MenuObjects[buttonId + 2] ), text1, NULL, false ); } GraphObjectDraw( &( MenuObjects[buttonId + 3] ), text2, NULL, false ); } } -void RemoveButton( uint8_t buttonId ) -{ +void RemoveButton( uint8_t buttonId ){ GraphObjectClear( &( MenuObjects[buttonId] ), true ); } -void DrawText( uint8_t lineId, uint8_t* text0, uint8_t* text1, uint8_t* text2 ) -{ - if( text0 != NULL ) - { +void DrawText( uint8_t lineId, uint8_t* text0, uint8_t* text1, uint8_t* text2 ){ + if( text0 != NULL ) { GraphObjectDraw( &( MenuObjects[lineId] ), text0, NULL, false ); } - if( text1 != NULL ) - { + if( text1 != NULL ) { GraphObjectDraw( &( MenuObjects[lineId + 1] ), text1, NULL, false ); } - if( text2 != NULL ) - { + if( text2 != NULL ) { GraphObjectDraw( &( MenuObjects[lineId + 2] ), text2, NULL, false ); } } -
diff -r 12c555cade79 -r b9d23a2f390e Display/Menu.h --- a/Display/Menu.h Thu Jan 20 13:26:03 2022 +0000 +++ b/Display/Menu.h Thu Feb 10 09:39:01 2022 +0000 @@ -12,50 +12,25 @@ Maintainer: Gregory Cristian & Gilbert Menth */ -#ifndef MENU_H -#define MENU_H - +//#ifndef MENU_H +//#define MENU_H -#include "DisplayDriver.h" -#include "DmTouchCalibration.h" - +//#include "DisplayDriver.h" +//#include "DmTouchCalibration.h" /*! * \brief TFT calibration structure. */ -typedef struct -{ - bool ScreenCalibrated; - CalibrationMatrix Calibration; -}MenuSettings_t; - -/*! - * \brief Available pages in menu. - */ -enum MenuPages -{ - START_PAGE = 0, - PAGE_PING_PONG, - PAGE_PER, - PAGE_RANGING_MASTER, - PAGE_RANGING_SLAVE, - PAGE_RANGING_PARAM, - PAGE_RADIO_PARAM, - PAGE_RADIO_PARAM_FREQ, - PAGE_UTILITIES, - PAGE_RADIO_TEST, - PAGE_SLEEP_MODE, - PAGE_STBY_RC_MODE, - PAGE_STBY_XOSC_MODE, - PAGE_TX_CW, - PAGE_CONT_MODULATION -}; - +//typedef struct +//{ +// bool ScreenCalibrated; +// CalibrationMatrix Calibration; +//}MenuSettings_t; /*! * \brief Common var to manage TFT calibration. */ -extern MenuSettings_t MenuSettings; +//extern MenuSettings_t MenuSettings; /*! @@ -66,281 +41,16 @@ // LA: New Master Menu // =============== // -void StabilusMenu (void); // LA: Prototype ... -void StabilusMainPage (uint8_t graphObjectTouched); // - -/*! - * \brief Permanently display Handler for touch sensor. - * - * \param [in] refresh Flag indicates refresh display required (touch) - * - * \retval CurrentPage The updated current page - */ -uint8_t MenuHandler( bool refresh ); - -/*! - * \brief Update or refresh the activated menu page. - * - * \param [in] page Page to display - */ -void MenuSetPage( uint8_t page ); - -/*! - * \brief Writes 3 lines on display, with current radio parameters. - * - * \param [in] page Current page to choose what to display. - */ -void DisplayCurrentRadioParams( uint8_t page ); - -/*! - * \brief Return text with current frame type. - * - * \retval text Pointer on text to display - */ -char* GetMenuRadioFrameType( void ); - -/*! - * \brief Return text with current Radio Modulation Parameters1. - * - * \retval text Pointer on text to display - */ -char* GetRadioModulationParameters1( void ); - -/*! - * \brief Return text with current Radio Modulatio nParameters2. - * - * \retval text Pointer on text to display - */ -char* GetRadioModulationParameters2( void ); - -/*! - * \brief Return text with current Radio Modulation Parameters3. - * - * \retval text Pointer on text to display - */ -char* GetRadioModulationParameters3( void ); - -/*! - * \brief Return text with current Radio Frequency. - * - * \retval text Pointer on text to display - */ -char* GetRadioFrequency( void ); -/*! - * \brief Update the radio frequency displayed on the screen. - * - * \param [in] freq freq in Hz - */ -void UpdateRadioFrequency( unsigned long freq ); - -/*! - * \brief Return text with current Radio Frequency [GHz] format #.###. - * - * \retval text Pointer on text to display - */ -char* GetRadioFrequencyGHz( void ); - -/*! - * \brief Return text with current Radio Freq Base. - * - * \retval text Pointer on text to display - */ -char* GetRadioFreqBase( void ); - -/*! - * \brief Return text with Radio preset Frequency 1. - * - * \retval text Pointer on text to display - */ -char* GetRadioFreqBasePS1( void ); - -/*! - * \brief Return text with Radio preset Frequency 2. - * - * \retval text Pointer on text to display - */ -char* GetRadioFreqBasePS2( void ); - -/*! - * \brief Return text with Radio preset Frequency 3. - * - * \retval text Pointer on text to display - */ -char* GetRadioFreqBasePS3( void ); - -/*! - * \brief Return text with current Radio Tx Power. - * - * \retval text Pointer on text to display - */ -char* GetRadioTxPower( void ); - -/*! - * \brief Return text with current Radio Payload Length. - * - * \retval text Pointer on text to display - */ -char* GetRadioPayloadLength( void ); - -/*! - * \brief Return text with Max Num Packet. - * - * \retval text Pointer on text to display - */ -char* GetMenuDemoMaxNumPacket( void ); - -/*! - * \brief Return text with current Demo Num Sent Packet. - * - * \retval text Pointer on text to display - */ -char* GetMenuDemoNumSentPacket( void ); - -/*! - * \brief Return text with current Rx frame Ok count. - * - * \retval text Pointer on text to display - */ -char* GetMenuDemoRxOk( void ); +//void StabilusMenu (int32_t i32_Pulses); +void StabilusMenu (uint32_t ms_0000, uint32_t ms_0001, uint32_t ms_0002, int32_t i32_Pulses); -/*! - * \brief Return text with current Rx frame Ko count. - * - * \retval text Pointer on text to display - */ -char* GetMenuDemoRxKo( void ); - -/*! - * \brief Return text with current Rx frame Ok (on slave side) count. - * - * \retval text Pointer on text to display - */ -char* GetMenuDemoRxOkSlave( void ); - -/*! - * \brief Return text with current Rx frame Ko (on slave side) count. - * - * \retval text Pointer on text to display - */ -char* GetMenuDemoRxKoSlave( void ); - -/*! - * \brief Return text with current Result PerCent1, format ###.##. - * - * \param [in] value value to compute in [%] - * \param [in] reference reference value for % computation - * - * \retval text Pointer on text to display - */ -char* GetMenuDemoResultPerCent1( uint32_t value, uint32_t reference ); - -/*! - * \brief Return text with current Result PerCent2, format ###.##. - * - * \param [in] value value to compute in [%] - * \param [in] reference reference value for % computation - * - * \retval text Pointer on text to display - */ -char* GetMenuDemoResultPerCent2( uint32_t value, uint32_t reference ); - -/*! - * \brief Return text with current Rssi. - * - * \retval text Pointer on text to display - */ -char* GetMenuDemoRssi( void ); - -/*! - * \brief Return text with current Snr. - * - * \retval text Pointer on text to display - */ -char* GetMenuDemoSnr( void ); - -/*! - * \brief Return text with current Antenna Setting. - * - * \retval text Pointer on text to display - */ -char* GetAntennaSetting( void ); - -/*! - * \brief Return text with Total Packet for the test. - * - * \retval text Pointer on text to display - */ -char* GetTotalPackets( void ); +//void CheckScreen( void ); +//void CheckRefresh( void ); +//void DebouncedScreen( void ); +void DrawActiveButton( uint8_t buttonId, uint8_t* text1, uint8_t* text2 ); +void ButtonChangeText( uint8_t buttonId, uint8_t* text1, uint8_t* text2 ); +void RemoveButton( uint8_t buttonId ); +void DrawText( uint8_t lineId, uint8_t* text0, uint8_t* text1, uint8_t* text2 ); -/*! - * \brief Return text with current GPS Time. - * - * \retval text Pointer on text to display - */ -char* GetGpsTime( void ); - -/*! - * \brief Return text with current GPS Position. - * - * \retval text Pointer on text to display - */ -char* GetGpsPos( void ); - -/*! - * \brief Return text with current Proximity Value. - * - * \retval text Pointer on text to display - */ -char* GetProximityValue( void ); - -/*! - * \brief Return text with current Radio Power Mode Value. - * - * \retval text Pointer on text to display - */ -char* GetMenuDemoRadioPowerMode( void ); - -/*! - * \brief Return text with current Frequency Error Value. - * - * \retval text Pointer on text to display - */ -char* GetFrequencyError( void ); +//#endif // MENU_H -/*! - * \brief Return text with current Ranging Channels Successfully Done Value. - * - * \retval text Pointer on text to display - */ -char* GetRngChannelsOk( void ); - -/*! - * \brief Return text with current Ranging Request Count Value. - * - * \retval text Pointer on text to display - */ -char* GetRangingRequestCount( void ); - -/*! - * \brief Return text with current Ranging Address Value. - * - * \retval text Pointer on text to display - */ -char* GetRangingAddress( void ); - -/*! - * \brief Return text with current Ranging Antenna Value. - * - * \retval text Pointer on text to display - */ -char* GetRangingAntenna( void ); - -/*! - * \brief Return text with current Ranging Distance Unit. - * - * \retval text Pointer on text to display - */ -char* GetRangingUnit( void ); - -#endif // MENU_H -
diff -r 12c555cade79 -r b9d23a2f390e Peripherals/Eeprom.h --- a/Peripherals/Eeprom.h Thu Jan 20 13:26:03 2022 +0000 +++ b/Peripherals/Eeprom.h Thu Feb 10 09:39:01 2022 +0000 @@ -19,7 +19,7 @@ #include "Menu.h" //#include "DemoApplication.h" //#include "sx1280.h" - +#include "DmTouchCalibration.h" /*! * \brief Define Buffer indexes for each EepromData for copy and restore @@ -96,6 +96,27 @@ */ #define EEPROM_BUFFER_SIZE 95 +/*! + * \brief Available pages in menu. + */ +enum MenuPages +{ + START_PAGE = 0, + PAGE_PING_PONG, + PAGE_PER, + PAGE_RANGING_MASTER, + PAGE_RANGING_SLAVE, + PAGE_RANGING_PARAM, + PAGE_RADIO_PARAM, + PAGE_RADIO_PARAM_FREQ, + PAGE_UTILITIES, + PAGE_RADIO_TEST, + PAGE_SLEEP_MODE, + PAGE_STBY_RC_MODE, + PAGE_STBY_XOSC_MODE, + PAGE_TX_CW, + PAGE_CONT_MODULATION +}; /*! * \brief Part of EEPROM to save or restore @@ -113,6 +134,15 @@ }EepromDataSet_t; /*! + * \brief TFT calibration structure. + */ +typedef struct +{ + bool ScreenCalibrated; + CalibrationMatrix Calibration; +}MenuSettings_t; + +/*! * \brief EepromData structure */ typedef struct
diff -r 12c555cade79 -r b9d23a2f390e QEI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QEI.lib Thu Feb 10 09:39:01 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/NHK-Robocon2016_Nagaoka_B_Team/code/QEI/#fe23b32e62ca
diff -r 12c555cade79 -r b9d23a2f390e SWPos/SWPos.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SWPos/SWPos.cpp Thu Feb 10 09:39:01 2022 +0000 @@ -0,0 +1,1019 @@ + +/* LA: Theory of Operation. +// ======================== +// +// once Encoder/Axis is Homed and Cycle Condition's Sussist, AC_Pos_Positioning is alloweed to take Control. +// This is done by keeping "STW1_Control" true. +// +// if Servolock is off, The Axis is then Set to "Free Wheel Axis" +// Otherwise, the System Keeps Actual Position (ServLock works inside the Tolerance window, if there's move), +// or a New Move is Started if Target is != Actual Position. +// +// if ServoLock is true and movement is alloweed, after the positioning will have Actual = Target, Tolerance +// flags active and a constant control to keep this. +// +// if "Axis" is Not Homed, All Positioning Flag(s) are kept clear +*/ + +/* LA: Verifica di coerenza del Profilo: +// ================================= +// +// Se Lo spazio di Accelerazione sommato a quello di Decelerazione, ad INIZIO MOVIMENTO, supera la distanza (in Modulo) da percorrere, +// allora il profilo và corretto (Non è più un trapezio ma diventa un triangolo). +// +// Per correggere il profilo occorre: +// +// 1) Calcolare le equazioni di entrambe le rette (Accelerazione e Decelerazione) +// 2) Ricavare il punto di intersezione delle due rette (La cui "Ascissa" sarà la velocità massima raggiungibile, l'"Ordinata" il punto a cui la raggiungerà) +// 3) Sostituire all'Accelerazione il valore "Ordinata"- Punto di Partenza (Verificando il segno dell'operazione in base al verso) +// 4) Sostituire alla Decelerazione il valore Destinazione - "Ordinata" (Verificando il segno dell'operazione in base al verso) +// 5) Sostituire alla Velocità di Movimento l'"Ascissa" +// +// Avendo già le equazioni di RettaxAcc e RettaxDec: +// ================================================= +// +// RettaxAcc: Y = (m * X)+ q +// RettaxDec: Y = (n * X)+ t +// +// Il punto X a cui le Y si equivalgono è X = (t- q)/ (m- n), la Y è ricavabile, indifferentemente, da entrambe le equazioni al punto X. +// Questo permetterà la corretta esecuzione del "Triangolo", col vertice alla "velocità massima calcolata" e rampe teoriche equivalenti a quelle programmate. +// +// **** +// **** +// **** +// **** +// +// Se non ho il "tempo" per calcolarlo uso un trucco: +// Se il profilo è da correggere (Acc+ Dec > Distance) carico in ActualSpeed la Velocità di Servolock e lascio che l'asse si muova alla "Minima". +// +*/ + +// LA: Includes +#include "mbed.h" +#include <stdio.h> +#include <stdlib.h> + +#include "SWPos.h" +#include "Timers.h" + +//in_sPosizionatoreSW in_PosizionatoreSW; +//out_sPosizionatoreSW out_PosizionatoreSW; + +// LA: Basic Function's Integration +void PosizionatoreSW (const in_sPosizionatoreSW &in, out_sPosizionatoreSW &out) { +static bool InProgress = false; + +static int64_t i64_TargetPosition_Prec; +static bool b_AuxCalculateProfile_003; +static bool b_AuxCalculateProfile_002; +static bool b_AuxCalculateProfile_001; +static bool b_AuxCalculateProfile_000; +static int32_t i32_ServoLockSpeed_FW; +static int32_t i32_ServoLockSpeed_BW; + +static double d_X1; +static double d_X2; +static double d_Y1; +static double d_Y2; +static double d_Y2_meno_Y1; +static double d_X2_meno_X1; +static double d_X2_per_Y1; +static double d_X1_per_Y2; +static double d_m; +static double d_q; +static double d_n; +static double d_t; + +static int32_t i32_ActualSpeed; +static int64_t i64_AccelerationWindow_Local; +static int64_t i64_DecelerationWindow_Local; +static int32_t i32_MaximumSpeed_FW; +static int32_t i32_MaximumSpeed_BW; +static int32_t i32_MaximumSpeed_Local; +static int64_t i64_StartPosition_Local; +static int64_t i64_Distance_Local; +static bool b_GoingFW; +static bool b_GoingBW; +static bool b_Accelerating_Local; +static bool b_Decelerating_Local; +static bool b_JogFW_Prec_Local; +static bool b_JogBW_Prec_Local; +static int32_t i32_Aux_ms2Acc; +static int32_t i32_Aux_ms2Dec; +static float f_Aux_AccelAnyms; +static float f_Aux_DecelAnyms; +static float f_MaximumJogSpeed_xW; + +static uint32_t ui32_PreviousStep_ms_Local; +uint32_t ui32_ActualStepSampled_ms_Local; +uint32_t ui32_PassedActual_ms_Local; + + if (InProgress) + return; + else { + InProgress = true; + + // LA: Generazione del millisecondo Attuale + // ==================================== + // + // Invoca il timer di sistema (TimersTimerValue) e lo confronta col suo precedente. + // Una volta elaborato e "scevrato" l'eventuale "Rollover" la sezione ritorna "ui32_PassedActual_ms_Local". + // "ui32_PassedActual_ms_Local" rappresenta i [ms] passati tra una chiamata e l'altra del Posizionatore SW. + // + ui32_ActualStepSampled_ms_Local = TimersTimerValue(); // Freezes the Actual Sample. + if (ui32_ActualStepSampled_ms_Local >= ui32_PreviousStep_ms_Local) + ui32_PassedActual_ms_Local = (ui32_ActualStepSampled_ms_Local- ui32_PreviousStep_ms_Local); // Result => Actual- Previous + else + ui32_PassedActual_ms_Local = ui32_ActualStepSampled_ms_Local+ (0x7fffffff- ui32_PreviousStep_ms_Local); // Result => Actual+ (Rollover- Previous) + // + ui32_PreviousStep_ms_Local = ui32_ActualStepSampled_ms_Local; // Store(s)&Hold(s) actual msSample + + // LA: Test pourposes ... + // + out.ui32_PreviousStep_ms = ui32_PreviousStep_ms_Local; + out.ui32_ActualStepSampled_ms = ui32_ActualStepSampled_ms_Local; + out.ui32_PassedActual_ms = ui32_PassedActual_ms_Local; + + // LA: Valutazione della Distanza (Rimanente) + // ====================================== + // + if (in.i64_ActualPosition > in.i64_TargetPosition) + i64_Distance_Local = (in.i64_ActualPosition- in.i64_TargetPosition); + else + i64_Distance_Local = (in.i64_TargetPosition- in.i64_ActualPosition); + + // LA: Entering SWPositioner + // ===================== + // + if (in.b_AxisPowered) { + if (in.b_JogMode) { + + // JOG Mode Engaged + // + if (in.b_JogFW) { + if (!b_JogFW_Prec_Local) { + + // JOG Mode FW "Just" Engaged + // + b_JogFW_Prec_Local = in.b_JogFW; + i32_Aux_ms2Acc = in.i32_JogAccel_ms; + // + f_MaximumJogSpeed_xW = (((in.f_JogSpeed_x100_FW)* (float)(in.i32_Max_Speed- i32_ActualSpeed)/ 100)); // LA: Speed to be Reached + f_Aux_AccelAnyms = (f_MaximumJogSpeed_xW/ (float)in.i32_JogAccel_ms); // LA: Any ms Increment o'Speed + + b_Accelerating_Local = true; + b_Decelerating_Local = false; + out.b_MaxSpeedReached = false; + } + + // JOG Move FW + // + if (i32_Aux_ms2Acc > 0) { + i32_Aux_ms2Acc = (i32_Aux_ms2Acc- ui32_PassedActual_ms_Local); // LA: Ms Passed @ this Trip + i32_ActualSpeed = (int32_t)((float)(in.i32_JogAccel_ms- i32_Aux_ms2Acc)* f_Aux_AccelAnyms); // LA: Acc Checkpoint + } + else { + i32_ActualSpeed = (int32_t)((in.f_JogSpeed_x100_FW)* (float)(in.i32_Max_Speed- in.i32_ZeroSpeed)/ 100); // LA: Maximum Speed Reached + + b_Accelerating_Local = false; + b_Decelerating_Local = false; + out.b_MaxSpeedReached = true; + } + b_GoingFW = true; // LA: Moves ... + b_GoingBW = false; // + } + else { + if (b_JogFW_Prec_Local) { + if (!b_Decelerating_Local) { + + // JOG Mode FW "Just" Released + // + i32_Aux_ms2Dec = in.i32_JogDecel_ms; + f_MaximumJogSpeed_xW = (((in.f_JogSpeed_x100_FW)* (float)(i32_ActualSpeed- in.i32_ZeroSpeed)/ 100)); // LA: Speed to be Reached + f_Aux_DecelAnyms = (f_MaximumJogSpeed_xW/ (float)in.i32_JogDecel_ms); // LA: Any ms Increment o'Speed + + b_Accelerating_Local = false; + b_Decelerating_Local = true; + out.b_MaxSpeedReached = false; + } + + // JOG Move FW, Decelerating to Zero + // + if (i32_Aux_ms2Dec > 0) { + i32_Aux_ms2Dec = (i32_Aux_ms2Dec- ui32_PassedActual_ms_Local); // LA: Ms Passed @ this Trip + i32_ActualSpeed = (int32_t)(f_MaximumJogSpeed_xW- (float)(in.i32_JogDecel_ms- i32_Aux_ms2Dec)* f_Aux_DecelAnyms); // LA: Dec Checkpoint + + b_GoingFW = true; // LA: Moves ... + b_GoingBW = false; // + } + else { + i32_ActualSpeed = in.i32_ZeroSpeed; // LA: Zero Speed Reached + + b_Accelerating_Local = false; + b_Decelerating_Local = false; + out.b_MaxSpeedReached = false; + // + b_JogFW_Prec_Local = false; // LA: Move is Terminated, NOW + b_GoingFW = false; // + b_GoingBW = false; // + } + } + } + + if (in.b_JogBW) { + if (!b_JogBW_Prec_Local) { + + // JOG Mode BW "Just" Engaged + // + b_JogBW_Prec_Local = in.b_JogBW; + i32_Aux_ms2Acc = in.i32_JogAccel_ms; + // + f_MaximumJogSpeed_xW = (((in.f_JogSpeed_x100_BW)* (float)(in.i32_Max_Speed- i32_ActualSpeed)/ 100)); // LA: Speed to be Reached + f_Aux_AccelAnyms = (f_MaximumJogSpeed_xW/ (float)in.i32_JogAccel_ms); // LA: Any ms Increment o'Speed + + b_Accelerating_Local = true; + b_Decelerating_Local = false; + out.b_MaxSpeedReached = false; + } + + // JOG Move BW + // + if (i32_Aux_ms2Acc > 0) { + i32_Aux_ms2Acc = (i32_Aux_ms2Acc- ui32_PassedActual_ms_Local); // LA: Ms Passed @ this Trip + i32_ActualSpeed = (int32_t)((float)(in.i32_JogAccel_ms- i32_Aux_ms2Acc)* f_Aux_AccelAnyms); // LA: Acc Checkpoint + } + else { + i32_ActualSpeed = (int32_t)((in.f_JogSpeed_x100_BW)* (float)(in.i32_Max_Speed- in.i32_ZeroSpeed)/ 100); // LA: Maximum Speed Reached + + b_Accelerating_Local = false; + b_Decelerating_Local = false; + out.b_MaxSpeedReached = true; + } + + b_GoingBW = true; // LA: Moves ... + b_GoingFW = false; // + } + else { + if (b_JogBW_Prec_Local) { + if (!b_Decelerating_Local) { + + // JOG Mode BW "Just" Released + // + i32_Aux_ms2Dec = in.i32_JogDecel_ms; + f_MaximumJogSpeed_xW = (((in.f_JogSpeed_x100_BW)* (float)(i32_ActualSpeed- in.i32_ZeroSpeed)/ 100)); // LA: Speed to be Reached + f_Aux_DecelAnyms = (f_MaximumJogSpeed_xW/ (float)(in.i32_JogDecel_ms)); // LA: Any ms Increment o'Speed + + b_Accelerating_Local = false; + b_Decelerating_Local = true; + out.b_MaxSpeedReached = false; + } + + // JOG Move FW, Decelerating to Zero + // + if (i32_Aux_ms2Dec > 0) { + i32_Aux_ms2Dec = (i32_Aux_ms2Dec- ui32_PassedActual_ms_Local); // LA: Ms Passed @ this Trip + i32_ActualSpeed = (int32_t)(f_MaximumJogSpeed_xW- (float)(in.i32_JogDecel_ms- i32_Aux_ms2Dec)* f_Aux_DecelAnyms); // LA: Dec Checkpoint + + b_GoingBW = true; // LA: Moves ... + b_GoingFW = false; // + } + else { + i32_ActualSpeed = in.i32_ZeroSpeed; // LA: Zero Speed Reached + + b_Accelerating_Local = false; + b_Decelerating_Local = false; + out.b_MaxSpeedReached = false; + // + b_JogBW_Prec_Local = false; // LA: Move is Terminated, NOW + b_GoingBW = false; // + b_GoingFW = false; // + } + } + } + out.b_Accelerating = b_Accelerating_Local; + out.b_Decelerating = b_Decelerating_Local; + } + + else { + // !in.b_JogMode + + // JOG Mode NOT Engaged + // Axis Powered + // + b_JogFW_Prec_Local = false; + b_JogBW_Prec_Local = false; + + if (in.b_ACPos_Homed) { + if ( + (in.rtServoLock_Q && (in.i64_TargetPosition != in.i64_ActualPosition)) || + (in.b_ServoLock && (in.i64_TargetPosition != i64_TargetPosition_Prec)) + ) { + + // LA: An Issue to the Motion to Start is then Present & Valid + // + i64_TargetPosition_Prec = in.i64_TargetPosition; + i64_StartPosition_Local = in.i64_ActualPosition; + + // wAccelerationWindow è già la Finestra di Accelerazione + // wDecelerationWindow è già la Finestra di Decelerazione + // wToleranceWindow è già la Finestra di Tolleranza di Posizionamento + // + i32_MaximumSpeed_FW = (int32_t)(((in.f_MaximumSpeed_x100_FW)* (float)(in.i32_Max_Speed- in.i32_ZeroSpeed)/ 100)); + i32_ServoLockSpeed_FW = (int32_t)(((in.f_ServoLockSpeed_x100_FW)* (float)(in.i32_Max_Speed- in.i32_ZeroSpeed)/ 100)); + i32_MaximumSpeed_BW = (int32_t)(((in.f_MaximumSpeed_x100_BW)* (float)(in.i32_Max_Speed- in.i32_ZeroSpeed)/ 100)); + i32_ServoLockSpeed_BW = (int32_t)(((in.f_ServoLockSpeed_x100_BW)* (float)(in.i32_Max_Speed- in.i32_ZeroSpeed)/ 100)); + + // LA: Verifica del Profilo (Trapezio o Triangolo) + // + if (i64_Distance_Local < (in.i64_AccelerationWindow+ in.i64_DecelerationWindow)) { + + // LA: Attenzione, il Profilo è Triangolare + // + if (in.i64_ActualPosition < in.i64_TargetPosition) { + + // LA: Going FW + // LA: Calcolare Entrambi i Profili, + // Trovare il Punto di Intersezione + // Aggiornare Acc/Dec/VMax in Accordo + + // Punto 1) Ricavo Y = mX+ q + // ================ + // + // Retta x due punti, partendo da (wStartPosition, i32_ZeroSpeed) + // (x1, Y1) + // x Giungere a (wStartPosition+ wAccelerationWindow, MaximumSpeed) + // (x2, Y2) + // + // Y = mX + q + // + // X = wActualPosition + // Y = ActualSpeed + // + // m = (y2- y1)/(x2- x1) + // q = ((x2* y1)- (x1* y2))/ (x2- x1) + // + // ================================== + // ================================== + + d_X1 = (double)i64_StartPosition_Local; + d_X2 = (double)(i64_StartPosition_Local+ in.i64_AccelerationWindow); + d_Y1 = (double)in.i32_ZeroSpeed; + d_Y2 = (double)i32_MaximumSpeed_FW; + + d_Y2_meno_Y1 = (d_Y2- d_Y1); // LA: From Zero to Max + d_X2_meno_X1 = (d_X2- d_X1); // LA: Acceleration EndPoint + d_X2_per_Y1 = (d_X2* d_Y1); + d_X1_per_Y2 = (d_X1* d_Y2); + + d_m = (d_Y2_meno_Y1)/ (d_X2_meno_X1); + d_q = ((d_X2_per_Y1)- (d_X1_per_Y2))/ (d_X2_meno_X1); + + // Punto 2) Ricavo Y = nX+ t + // ================ + // + // Retta x due punti, partendo da (wTargetPosition- wDecelerationWindow, MaximumSpeed) + // (x1, Y1) + // x Giungere a (wTargetPosition, i32_ZeroSpeed) + // (x2, Y2) + // + // Y = nX + t + // + // X = wActualPosition + // Y = ActualSpeed + // + // n = (y2- y1)/(x2- x1) + // t = ((x2* y1)- (x1* y2))/ (x2- x1) + // + // ================================== + // ================================== + + d_X1 = (double)(in.i64_TargetPosition- in.i64_DecelerationWindow); + d_X2 = (double)in.i64_TargetPosition; + d_Y1 = (double)i32_ActualSpeed; // LA: Maximum Speed Planned MIGHT have NOT been Reached + d_Y2 = (double)in.i32_ZeroSpeed; + + d_Y2_meno_Y1 = (d_Y2- d_Y1); // LA: From Max to Zero + d_X2_meno_X1 = (d_X2- d_X1); // LA: Deceleration EndPoint + d_X2_per_Y1 = (d_X2* d_Y1); + d_X1_per_Y2 = (d_X1* d_Y2); + + d_n = (d_Y2_meno_Y1)/ (d_X2_meno_X1); + d_t = ((d_X2_per_Y1)- (d_X1_per_Y2))/ (d_X2_meno_X1); + + // Punto 3) Rilevo il punto di Intersezione x la X + // Ricavo conseguentemente Y dall'equazione + // ======================================== + // + // X = (t- q)/ (m- n) + // Y = mX+ q (o Y = nX+ t, che in quel punto è equivalente ...) + // + // Y Rappresenterà la Massima Velocità raggiungibile, con le attuali pendenze + // X Rappresenta il punto a cui ridurre Accelerazioni e Decelerazioni di profilo. + // + // PQM: + // + // Accwindow = ((t- q)/ (m- n))- StartPosition + // Decwindow = FinishPosition- ((t- q)/ (m- n)) + // MaxSpeed = (m* ((t- q)/ (m- n))) + q + + i64_AccelerationWindow_Local = (long)(((d_t- d_q)/ (d_m- d_n))- (double)i64_StartPosition_Local); + i64_DecelerationWindow_Local = (long)((double)i64_StartPosition_Local- ((d_t- d_q)/ (d_m- d_n))); + i32_MaximumSpeed_Local = (int32_t)((d_m* ((d_t- d_q)/ (d_m- d_n)))+ d_q); + } + + else { + + // uui64_ActualPosition >= uui64_TargetPosition + // LA: Going BW + // LA: Calcolare Entrambi i Profili, + // Trovare il Punto di Intersezione + // Aggiornare Acc/Dec/VMax in Accordo + + // Punto 1) Ricavo Y = mX+ q + // ================ + // + // Retta x due punti, partendo da (wStartPosition, i32_ZeroSpeed) + // (x1, Y1) + // x Giungere a (wStartPosition- wAccelerationWindow, MaximumSpeed) + // (x2, Y2) + // + // Y = mX + q + // + // X = wActualPosition + // Y = ActualSpeed + // + // m = (y2- y1)/(x2- x1) + // q = ((x2* y1)- (x1* y2))/ (x2- x1) + // + // ================================== + // ================================== + + d_X1 = (double)i64_StartPosition_Local; + d_X2 = (double)(i64_StartPosition_Local- in.i64_AccelerationWindow); + d_Y1 = (double)in.i32_ZeroSpeed; + d_Y2 = (double)i32_MaximumSpeed_BW; + + d_Y2_meno_Y1 = (d_Y2- d_Y1); // LA: From Zero to Max + d_X2_meno_X1 = (d_X2- d_X1); // LA: Acceleration EndPoint + d_X2_per_Y1 = (d_X2* d_Y1); + d_X1_per_Y2 = (d_X1* d_Y2); + + d_m = (d_Y2_meno_Y1)/ (d_X2_meno_X1); + d_q = ((d_X2_per_Y1)- (d_X1_per_Y2))/ (d_X2_meno_X1); + + b_AuxCalculateProfile_002 = true; + + // Punto 2) Ricavo Y = nX+ t + // ================ + // + // Retta x due punti, partendo da (wTargetPosition+ wDecelerationWindow, MaximumSpeed) + // (x1, Y1) + // x Giungere a (wTargetPosition, i32_ZeroSpeed) + // (x2, Y2) + // + // Y = mX + q + // + // X = wActualPosition + // Y = ActualSpeed + // + // m = (y2- y1)/(x2- x1) + // q = ((x2* y1)- (x1* y2))/ (x2- x1) + // + // ================================== + // ================================== + + d_X1 = (double)(in.i64_TargetPosition + in.i64_DecelerationWindow); + d_X2 = (double)(in.i64_TargetPosition); + d_Y1 = (double)(i32_ActualSpeed); // LA: Maximum Speed Planned MIGHT have NOT been Reached + d_Y2 = (double)(in.i32_ZeroSpeed); + + d_Y2_meno_Y1 = (d_Y2- d_Y1); // LA: From Max to Zero + d_X2_meno_X1 = (d_X2- d_X1); // LA: Deceleration EndPoint + d_X2_per_Y1 = (d_X2* d_Y1); + d_X1_per_Y2 = (d_X1* d_Y2); + + d_n = (d_Y2_meno_Y1)/ (d_X2_meno_X1); + d_t = ((d_X2_per_Y1)- (d_X1_per_Y2))/ (d_X2_meno_X1); + + // Punto 3) Rilevo il punto di Intersezione x la X + // Ricavo conseguentemente Y dall'equazione + // ======================================== + // + // X = (t- q)/ (m- n) + // Y = mX+ q (o Y = nX+ t, che in quel punto è equivalente ...) + // + // Y Rappresenterà la Massima Velocità raggiungibile, con le attuali pendenze + // X Rappresenta il punto a cui ridurre Accelerazioni e Decelerazioni di profilo. + // + // PQM: + // + // Accwindow = StartPosition- ((t- q)/ (m- n)) + // Decwindow = ((t- q)/ (m- n))- FinishPosition + // MaxSpeed = (m* ((t- q)/ (m- n))) + q + + i64_AccelerationWindow_Local = (long)((double)i64_StartPosition_Local- ((d_t- d_q)/ (d_m- d_n))); + i64_DecelerationWindow_Local = (long)(((d_t- d_q)/ (d_m- d_n))- (double)i64_StartPosition_Local); + i32_MaximumSpeed_Local = (int32_t)((d_m* ((d_t- d_q)/ (d_m- d_n)))+ d_q); + } + } + else { + + // LA: il Profilo è Trapeziodale, Nullaltro da fare che assegnare i valori ai contenitori locali. + // + i64_AccelerationWindow_Local = in.i64_AccelerationWindow; + i64_DecelerationWindow_Local = in.i64_DecelerationWindow; + + if (in.i64_ActualPosition < in.i64_TargetPosition) + i32_MaximumSpeed_Local = i32_MaximumSpeed_FW; // LA: Going FW + else + i32_MaximumSpeed_Local = i32_MaximumSpeed_BW; // LA: Going BW + } + + b_GoingFW = false; + out.b_InToleranceFW = false; + b_GoingBW = false; + out.b_InToleranceBW = false; + + out.b_Accelerating = false; + out.b_MaxSpeedReached = false; + out.b_Decelerating = false; + out.b_InPosition = false; + + b_AuxCalculateProfile_000 = false; + b_AuxCalculateProfile_001 = false; + b_AuxCalculateProfile_002 = false; + b_AuxCalculateProfile_003 = false; + } + + if (!in.b_ServoLock) { + + // LA: Stop the Motion + // + i32_ActualSpeed = in.i32_ZeroSpeed; + b_GoingFW = false; + b_GoingBW = false; + + out.b_STW1_On = false; + out.b_STW1_NoCStop = false; + out.b_STW1_NoQStop = false; + out.b_STW1_Enable = false; + + // LA: i64_TargetPosition_Prec è ritentiva, per cui è bene inizializzarla != uui64_TargetPosition. + // + if (in.i64_TargetPosition > 0) // LA: E' Possibile Decrementare senza rollare? + i64_TargetPosition_Prec = in.i64_TargetPosition- 1; // LA: Si, Di certo Diverso, Di certo Coerente. + else + i64_TargetPosition_Prec = in.i64_TargetPosition+ 1; // LA: No, Incremento. Di certo è Diverso e Coerente. + + // ======================== + // ======================== + // Axis is Now "Free Wheel" + // ======================== + // ======================== + + } + + else { + + // LA: Issue to <Start the Motion> + // LA: Keep the present Motion <Active> + // + out.b_STW1_On = true; + out.b_STW1_NoCStop = true; + out.b_STW1_NoQStop = true; + out.b_STW1_Enable = true; + + // Positioner + // + if (in.i64_ActualPosition < in.i64_TargetPosition) { + + // LA: Going FW + // + out.b_InToleranceBW = false; + b_GoingFW = true; + b_GoingBW = false; + + // Case is: Acceleration is Alloweed + // ======================== + // + if ( + (in.i64_ActualPosition >= i64_StartPosition_Local) && + (in.i64_ActualPosition < (i64_StartPosition_Local+ i64_AccelerationWindow_Local)) + ) { + + out.b_Accelerating = true; + out.b_Decelerating = false; + out.b_MaxSpeedReached = false; + + out.b_InPosition = false; + out.b_InToleranceFW = false; + + // Line Profile [m, q] is to be Calculated only once + // + if (! b_AuxCalculateProfile_000) { + + // Retta x due punti, partendo da (wStartPosition, i32_ZeroSpeed) + // (x1, Y1) + // x Giungere a (wStartPosition+ wAccelerationWindow, MaximumSpeed) + // (x2, Y2) + // + // Y = mX + q + // + // X = wActualPosition + // Y = ActualSpeed + // + // m = (y2- y1)/(x2- x1) + // q = ((x2* y1)- (x1* y2))/ (x2- x1) + // + // ================================== + // ================================== + + d_X1 = (double)i64_StartPosition_Local; + d_X2 = (double)(i64_StartPosition_Local+ i64_AccelerationWindow_Local); + d_Y1 = (double)in.i32_ZeroSpeed; + d_Y2 = (double)i32_MaximumSpeed_Local; + + d_Y2_meno_Y1 = (d_Y2- d_Y1); // LA: From Zero to Max + d_X2_meno_X1 = (d_X2- d_X1); // LA: Acceleration EndPoint */ + d_X2_per_Y1 = (d_X2* d_Y1); + d_X1_per_Y2 = (d_X1* d_Y2); + + d_m = (d_Y2_meno_Y1)/ (d_X2_meno_X1); + d_q = ((d_X2_per_Y1)- (d_X1_per_Y2))/ (d_X2_meno_X1); + + b_AuxCalculateProfile_000 = true; + } + + i32_ActualSpeed = (int)((d_m * (double)in.i64_ActualPosition)+ d_q); + } + + // Case is: MiddleWalking @ Planned-Full Speed + // ================================== + // + if ( + (in.i64_ActualPosition >= (i64_StartPosition_Local+ i64_AccelerationWindow_Local)) && + (in.i64_ActualPosition < (in.i64_TargetPosition - i64_DecelerationWindow_Local)) + ) { + + out.b_Accelerating = false; + out.b_Decelerating = false; + out.b_MaxSpeedReached = true; + + out.b_InPosition = false; + out.b_InToleranceFW = false; + + i32_ActualSpeed = i32_MaximumSpeed_Local; + } + + // Case is: Need to Decelerate, up to the Tolerance Window + // ============================================== + // + if ( + (in.i64_ActualPosition >= (in.i64_TargetPosition- i64_DecelerationWindow_Local)) && + (in.i64_ActualPosition < (in.i64_TargetPosition- in.i64_diToleranceWindow)) + ) { + + out.b_Accelerating = false; + out.b_Decelerating = true; + out.b_MaxSpeedReached = false; + + out.b_InPosition = false; + out.b_InToleranceFW = false; + + // Line Profile [m, q] is to be Calculated only once + // + if (! b_AuxCalculateProfile_001) { + + // Retta x due punti, partendo da (wTargetPosition- wDecelerationWindow, MaximumSpeed) + // (x1, Y1) + // x Giungere a (wTargetPosition, i32_ZeroSpeed) + // (x2, Y2) + // + // Y = mX + q + // + // X = wActualPosition + // Y = ActualSpeed + // + // m = (y2- y1)/(x2- x1) + // q = ((x2* y1)- (x1* y2))/ (x2- x1) + // + // ================================== + // ================================== + + d_X1 = (double)(in.i64_TargetPosition- i64_DecelerationWindow_Local); + d_X2 = (double)in.i64_TargetPosition; + d_Y1 = (double)i32_ActualSpeed; // LA: Maximum Speed Planned MIGHT have NOT been Reached + d_Y2 = (double)in.i32_ZeroSpeed; + + d_Y2_meno_Y1 = (d_Y2- d_Y1); // LA: From Max to Zero + d_X2_meno_X1 = (d_X2- d_X1); // LA: Deceleration EndPoint + d_X2_per_Y1 = (d_X2* d_Y1); + d_X1_per_Y2 = (d_X1* d_Y2); + + d_m = (d_Y2_meno_Y1)/ (d_X2_meno_X1); + d_q = ((d_X2_per_Y1)- (d_X1_per_Y2))/ (d_X2_meno_X1); + + b_AuxCalculateProfile_001 = true; + } + + i32_ActualSpeed = abs((int)((d_m * (double)in.i64_ActualPosition)+ d_q)); + } + + // Case is: Tolerance Reached while Going FW + // ================================ + // + if (in.i64_ActualPosition >= (in.i64_TargetPosition- in.i64_diToleranceWindow)) { + out.b_Accelerating = false; + out.b_Decelerating = false; + out.b_MaxSpeedReached = false; + + out.b_InPosition = true; + out.b_InToleranceFW = true; + + i64_StartPosition_Local = in.i64_ActualPosition; + i32_ActualSpeed = i32_ServoLockSpeed_FW; + } + } + + else if (in.i64_ActualPosition > in.i64_TargetPosition) { + + // LA: Going Bw + // + out.b_InToleranceFW = false; + b_GoingBW = true; + b_GoingFW = false; + + // Case is: Acceleration is Alloweed + // ======================== + // + if ( + (in.i64_ActualPosition <= i64_StartPosition_Local) && + (in.i64_ActualPosition > (i64_StartPosition_Local- i64_AccelerationWindow_Local)) + ) { + + out.b_Accelerating = true; + out.b_Decelerating = false; + out.b_MaxSpeedReached = false; + + out.b_InPosition = false; + out.b_InToleranceBW = false; + + // Line Profile [m, q] is to be Calculated only once + // + if (! b_AuxCalculateProfile_002) { + + // Retta x due punti, partendo da (wStartPosition, i32_ZeroSpeed) + // (x1, Y1) + // x Giungere a (wStartPosition- wAccelerationWindow, MaximumSpeed) + // (x2, Y2) + // + // Y = mX + q + // + // X = wActualPosition + // Y = ActualSpeed + // + // m = (y2- y1)/(x2- x1) + // q = ((x2* y1)- (x1* y2))/ (x2- x1) + // + // ================================== + // ================================== + + d_X1 = (double)i64_StartPosition_Local; + d_X2 = (double)(i64_StartPosition_Local- i64_AccelerationWindow_Local); + d_Y1 = (double)in.i32_ZeroSpeed; + d_Y2 = (double)i32_MaximumSpeed_Local; + + d_Y2_meno_Y1 = (d_Y2- d_Y1); // LA: From Zero to Max + d_X2_meno_X1 = (d_X2- d_X1); // LA: Acceleration EndPoint + d_X2_per_Y1 = (d_X2* d_Y1); + d_X1_per_Y2 = (d_X1* d_Y2); + + d_m = (d_Y2_meno_Y1)/ (d_X2_meno_X1); + d_q = ((d_X2_per_Y1)- (d_X1_per_Y2))/ (d_X2_meno_X1); + + b_AuxCalculateProfile_002 = true; + } + + i32_ActualSpeed = (int)((d_m * (double)in.i64_ActualPosition)+ d_q); + } + + // Case is: MiddleWalking @ Planned-Full Speed + // ================================== + // + if ( + (in.i64_ActualPosition <= (i64_StartPosition_Local- i64_AccelerationWindow_Local)) && + (in.i64_ActualPosition > (in.i64_TargetPosition+ i64_DecelerationWindow_Local)) + ) { + + out.b_Accelerating = false; + out.b_Decelerating = false; + out.b_MaxSpeedReached = true; + + out.b_InPosition = false; + out.b_InToleranceBW = false; + + i32_ActualSpeed = i32_MaximumSpeed_Local; + } + + // Case is: Need to Decelerate, up to the Tolerance Window + // ============================================== + // + if ( + (in.i64_ActualPosition <= (in.i64_TargetPosition+ i64_DecelerationWindow_Local)) && + (in.i64_ActualPosition > (in.i64_TargetPosition+ in.i64_diToleranceWindow)) + ) { + + out.b_Accelerating = false; + out.b_Decelerating = true; + out.b_MaxSpeedReached = false; + + out.b_InPosition = false; + out.b_InToleranceBW = false; + + // Line Profile [m, q] is to be Calculated only once + // + if (! b_AuxCalculateProfile_003) { + + // Retta x due punti, partendo da (wTargetPosition+ wDecelerationWindow, MaximumSpeed) + // (x1, Y1) + // x Giungere a (wTargetPosition, i32_ZeroSpeed) + // (x2, Y2) + // + // Y = mX + q + // + // X = wActualPosition + // Y = ActualSpeed + // + // m = (y2- y1)/(x2- x1) + // q = ((x2* y1)- (x1* y2))/ (x2- x1) + // + // ================================== + // ================================== + + d_X1 = (double)(in.i64_TargetPosition + i64_DecelerationWindow_Local); + d_X2 = (double)in.i64_TargetPosition; + d_Y1 = (double)i32_ActualSpeed; // LA: Maximum Speed Planned MIGHT have NOT been Reached + d_Y2 = (double)in.i32_ZeroSpeed; + + d_Y2_meno_Y1 = (d_Y2- d_Y1); // LA: From Max to Zero + d_X2_meno_X1 = (d_X2- d_X1); // LA: Deceleration EndPoint + d_X2_per_Y1 = (d_X2* d_Y1); + d_X1_per_Y2 = (d_X1* d_Y2); + + d_m = (d_Y2_meno_Y1)/ (d_X2_meno_X1); + d_q = ((d_X2_per_Y1)- (d_X1_per_Y2))/ (d_X2_meno_X1); + + b_AuxCalculateProfile_003 = true; + } + + i32_ActualSpeed = abs((int)((d_m* (double)(in.i64_ActualPosition))+ d_q)); + } + + // Case is: Tolerance Reached while Going BW + // ================================ + // + if (in.i64_ActualPosition <= (in.i64_TargetPosition + in.i64_diToleranceWindow)) { + out.b_Accelerating = false; + out.b_Decelerating = false; + out.b_MaxSpeedReached = false; + + out.b_InPosition = true; + out.b_InToleranceBW = true; + + i64_StartPosition_Local = in.i64_ActualPosition; + i32_ActualSpeed = i32_ServoLockSpeed_BW; + } + } + + else { + + // LA: In Position + // =========== + // + b_GoingBW = false; + out.b_InToleranceBW = true; + b_GoingFW = false; + out.b_InToleranceFW = true; + + out.b_Accelerating = false; + out.b_Decelerating = false; + out.b_MaxSpeedReached = false; + + out.b_InPosition = true; + + i64_StartPosition_Local = in.i64_ActualPosition; + i32_ActualSpeed = in.i32_ZeroSpeed; + } + + // Arrivato Qui 07/02/2022 + // Arrivato Qui 07/02/2022 + // Arrivato Qui 07/02/2022 + // Arrivato Qui 07/02/2022 + + // =========================== + // =========================== + // LA: Managing the Speed Limit(s) + // =========================== + // =========================== + + if (i64_Distance_Local >= in.i64_diToleranceWindow) { + // i64_Distance_Local >= in.i64_diToleranceWindow + + if (in.i64_ActualPosition < in.i64_TargetPosition) { + + // LA: Going FW + // + if (i32_ActualSpeed > i32_MaximumSpeed_FW) + i32_ActualSpeed = i32_MaximumSpeed_FW; + if (i32_ActualSpeed < i32_ServoLockSpeed_FW) + i32_ActualSpeed = i32_ServoLockSpeed_FW; + } + else { + + // LA: Going BW + // + if (i32_ActualSpeed > i32_MaximumSpeed_BW) + i32_ActualSpeed = i32_MaximumSpeed_BW; + if (i32_ActualSpeed < i32_ServoLockSpeed_BW) + i32_ActualSpeed = i32_ServoLockSpeed_BW; + } + } + + else { + // i64_Distance_Local < in.i64_diToleranceWindow + + // LA: Attenzione, questo esegue un OVERRIDE alle assegnazioni precedenti. + // =================================================================== + // + // Se il controllo di distanza vede che l'asse è in Anello di tolleranza forza a Zerospeed la velocità. + // Il comportamento conseguente è che l'asse rimane in quiete, senza correnti applicate, fintanto che resta all'interno della finestra. + // Se dovesse uscire, il sistema lo riporterebbe in tolleranza (o cercherebbe di farlo) a "ServolockSpeed". + // + + i32_ActualSpeed = in.i32_ZeroSpeed; + } + } + } + + else { + // !in.b_ACPos_Homed + + // LA: if Not Homed, Positioning Flag(s) are Kept Clear + // + b_GoingFW = false; + out.b_InToleranceFW = false; + b_GoingBW = false; + out.b_InToleranceBW = false; + + out.b_Accelerating = false; + out.b_MaxSpeedReached = false; + out.b_Decelerating = false; + out.b_InPosition = false; + + b_AuxCalculateProfile_000 = false; + b_AuxCalculateProfile_001 = false; + b_AuxCalculateProfile_002 = false; + b_AuxCalculateProfile_003 = false; + + i32_ActualSpeed = in.i32_ZeroSpeed; + } + } + } + else { + // !in.b_AxisPowered + + // LA: if Not Powered, Motion Flag(s) are Kept Clear + // + b_GoingFW = false; + out.b_InToleranceFW = false; + b_GoingBW = false; + out.b_InToleranceBW = false; + + out.b_Accelerating = false; + out.b_MaxSpeedReached = false; + out.b_Decelerating = false; + out.b_InPosition = false; + + b_AuxCalculateProfile_000 = false; + b_AuxCalculateProfile_001 = false; + b_AuxCalculateProfile_002 = false; + b_AuxCalculateProfile_003 = false; + + i32_ActualSpeed = in.i32_ZeroSpeed; + } + + // =================== + // =================== + // LA: Finally, RAW Output + // =================== + // =================== + + out.i32_ATVSpeed = i32_ActualSpeed; + out.b_ATVDirectionFW = b_GoingFW; + out.b_ATVDirectionBW = b_GoingBW; + + out.i64_StartPosition = i64_StartPosition_Local; + out.i64_Distance = i64_Distance_Local; + } + InProgress = false; +}
diff -r 12c555cade79 -r b9d23a2f390e SWPos/SWPos.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SWPos/SWPos.h Thu Feb 10 09:39:01 2022 +0000 @@ -0,0 +1,62 @@ +#include "mbed.h" + +struct in_sPosizionatoreSW { + bool b_AxisPowered; + bool b_ACPos_Homed; + int32_t i32_Max_Speed; + int32_t i32_ZeroSpeed; + + bool b_JogMode; + bool b_JogFW; + bool b_JogBW; + // + int32_t i32_JogAccel_ms; + int32_t i32_JogDecel_ms; + // + float f_JogSpeed_x100_FW; // in_rJogSpeed%_FW + float f_JogSpeed_x100_BW; // in_rJogSpeed%_BW + + bool b_ServoLock; + bool rtServoLock_Q; + // + int64_t i64_TargetPosition; + int64_t i64_ActualPosition; + int64_t i64_AccelerationWindow; + int64_t i64_DecelerationWindow; + int64_t i64_diToleranceWindow; + // + float f_ServoLockSpeed_x100_FW; // in_rServoLockSpeed%_FW + float f_ServoLockSpeed_x100_BW; // in_rServoLockSpeed%_BW + float f_MaximumSpeed_x100_FW; // LA: in_rMaximumSpeed%_FW + float f_MaximumSpeed_x100_BW; // LA: in_rMaximumSpeed%_BW +}; + +struct out_sPosizionatoreSW { + int64_t i64_StartPosition; + int64_t i64_Distance; + + bool b_Accelerating; // LA: bACPos_Accelerating + bool b_MaxSpeedReached; + // + bool b_Decelerating; // bACPos_Decelerating + bool b_InPosition; + bool b_InToleranceFW; + bool b_InToleranceBW; + + int32_t i32_ATVSpeed; + bool b_ATVDirectionFW; + bool b_ATVDirectionBW; + // + bool b_STW1_On; + bool b_STW1_NoCStop; + bool b_STW1_NoQStop; + bool b_STW1_Enable; + + // LA: Disposizioni transitorie e finali + // + uint32_t ui32_PreviousStep_ms; + uint32_t ui32_ActualStepSampled_ms; + uint32_t ui32_PassedActual_ms; +}; + +void PosizionatoreSW (const in_sPosizionatoreSW &in, out_sPosizionatoreSW &out);
diff -r 12c555cade79 -r b9d23a2f390e main.cpp --- a/main.cpp Thu Jan 20 13:26:03 2022 +0000 +++ b/main.cpp Thu Feb 10 09:39:01 2022 +0000 @@ -1,38 +1,181 @@ -#include "mbed.h" +//Warning: Incompatible redefinition of macro "MBED_RAM_SIZE" in "tmp/HU5Hqj", Line: 39, Col: 10 +#ifndef MBED_RAM_SIZE +#define MBED_RAM_SIZE 0x00018000 +#endif + +//#include "mbed.h" +#include "QEI.h" +#include "SWPos.h" + #include "Timers.h" -#include "Menu.h" +//#include "Menu.h" #include "Eeprom.h" -#include "main.h" -#include "app_config.h" +//#include "main.h" +//#include "app_config.h" /*! * \brief Define IO for Unused Pin */ -DigitalOut F_CS( D6 ); // MBED description of pin -DigitalOut SD_CS( D8 ); // MBED description of pin -DigitalIn userButton( USER_BUTTON ); +//DigitalOut F_CS (D6); // MBED description of pin +//DigitalOut SD_CS (D8); // MBED description of pin + +DigitalIn userButton (USER_BUTTON); -int main (void){ - F_CS = 1; // LA: HW Initialization InProgress - SD_CS = 1; // LA: HW Initialization InProgress +AnalogIn adc_temp (ADC_TEMP); +AnalogIn adc_vref (ADC_VREF); +AnalogIn adc_vbat (ADC_VBAT); - EepromInit( ); // LA: Inizializza la EEProm +// PWM +// === +// +//PwmOut PWM_PB3(PWM_OUT); // LA: PWM_OUT = D3 = PB_3 - // LA: FactoryReset se "userButton" premuto all'avvio - // - if (userButton == 0) { - FactoryReset( ); - } +// Motion +// ====== +// +//Ticker POS_MotionScan; // - MenuInit( ); // LA: Inizializza il Display +QEI Stabilus322699 (PA_1, PA_0, NC, 100, QEI::X4_ENCODING); +// +in_sPosizionatoreSW in_PosizionatoreSW; +out_sPosizionatoreSW out_PosizionatoreSW; - while (1) { - StabilusMenu (); - } -} +// LCD Display +// =========== +// +//Ticker LCD_RefreshViews; // + +//extern void StabilusMenu (uint32_t, uint32_t, int64_t); // LA: Prototype ... void FactoryReset (void) { EepromFactoryReset( ); HAL_NVIC_SystemReset( ); } + +/* +void LCD____tScan (void) { +// StabilusMenu (out_PosizionatoreSW.ui32_PreviousStep_ms, out_PosizionatoreSW.ui32_ActualStepSampled_ms, out_PosizionatoreSW.ui32_PassedActual_ms); +} + + +void Motion_tScan (void) { + PosizionatoreSW (in_PosizionatoreSW, out_PosizionatoreSW); +} +*/ + +// ======= +// ======= +// Main(s) +// ======= +// ======= +// +int main (void){ +//int32_t i32_Pulses; +// F_CS = 1; // LA: HW Initialization InProgress +// SD_CS = 1; // LA: HW Initialization InProgress +// BoardLED3 = 1; + + EepromInit(); // LA: Inizializza la EEProm + TimersInit(); // LA: Parte il Timer a 1ms + + // LA: FactoryReset se "userButton" premuto all'avvio + // + if (userButton == 0) { + FactoryReset(); + } + + MenuInit(); // LA: Inizializza il Display +// LCD_RefreshViews.attach_us (&LCD____tScan, 250000); // Scansione LCD @100ms + + // LA: Motion (1st) Setup + // + in_PosizionatoreSW.b_AxisPowered = false; + in_PosizionatoreSW.b_ACPos_Homed = false; + in_PosizionatoreSW.i32_Max_Speed = 1024; // [ui] + in_PosizionatoreSW.i32_ZeroSpeed = 0; // + + in_PosizionatoreSW.b_JogMode = false; + in_PosizionatoreSW.b_JogFW = false; + in_PosizionatoreSW.b_JogBW = false; + in_PosizionatoreSW.i32_JogAccel_ms = 500; // [ms] + in_PosizionatoreSW.i32_JogDecel_ms = 250; // + // + in_PosizionatoreSW.f_JogSpeed_x100_FW = 25.0; // % of "i32_Max_Speed" + in_PosizionatoreSW.f_JogSpeed_x100_BW = 25.0; // + + in_PosizionatoreSW.b_ServoLock = false; + in_PosizionatoreSW.rtServoLock_Q = false; + // + in_PosizionatoreSW.i64_TargetPosition = 0; // [ui] + in_PosizionatoreSW.i64_ActualPosition = 0; // + in_PosizionatoreSW.i64_AccelerationWindow = 0; // LA: Spazio concesso all'accelerazione. + in_PosizionatoreSW.i64_DecelerationWindow = 0; // Spazio concesso alla decelerazione, è prioritario rispetto all'accelerazione. + in_PosizionatoreSW.i64_diToleranceWindow = 0; // Finestra di Tolleranza + // + in_PosizionatoreSW.f_MaximumSpeed_x100_FW = 25.0; // % of "i32_Max_Speed" + in_PosizionatoreSW.f_MaximumSpeed_x100_BW = 25.0; // + in_PosizionatoreSW.f_ServoLockSpeed_x100_FW = 5.0; // + in_PosizionatoreSW.f_ServoLockSpeed_x100_BW = 5.0; // + +// POS_MotionScan.attach_us (&Motion_tScan, 2000); // LA: Scansione Motion @2ms + +// PWM_SetOut.attach_us (&PWM____tScan, 100); // Scansione base PWM @100us Ok +// PWM_SetOut.attach_us (&PWM____tScan, 50); // Scansione base PWM @50us Ok +// PWM_SetOut.attach_us (&PWM____tScan, 30); // Scansione base PWM @30us Ok +// PWM_SetOut.attach_us (&PWM____tScan, 25); // Scansione base PWM @25us No (al pelo ...) +// PWM_SetOut.attach_us (&PWM____tScan, 10); // Scansione base PWM @10us No (al pelo ...) +// PWM_SetOut.attach_us (&PWM____tScan, 20); // Scansione base PWM @20us No + +// PWM_SetOut.attach_us (&PWM____tScan, 40); // Scansione base PWM @40us, Duty Cycle 4ms, 0- 100% +// PWM_SetOut.attach_us (&PWM____tScan, 100); // Scansione base PWM @40us, Duty Cycle 5ms, 0- 100% + +// PWM_PB3.period_us(100); // LA: TimeBase is 100us +// PWM_PB3.pulsewidth_us(50); // 0.. 100us -> 0.. 100% + + while (1) { +// int32_t i32_Pulses; +// i32_Pulses = Stabilus322699.getPulses(); + + // LA: Wedge 4 LCDRefresh + StabilusMenu (out_PosizionatoreSW.ui32_PreviousStep_ms, out_PosizionatoreSW.ui32_ActualStepSampled_ms, out_PosizionatoreSW.ui32_PassedActual_ms, Stabilus322699.getPulses()); +// StabilusMenu (0, 1, 2, i32_Pulses); +// StabilusMenu (0, 1, i32_Pulses); +// StabilusMenu (0, 0, 0); // i32_Pulses); +// StabilusMenu (); // i32_Pulses); +// StabilusMenu (1); // i32_Pulses); + +/* + PWM_PB3 = PWM_PB3+ (float)0.01; + wait_ms(10); + + if (PWM_PB3 >= (float)1.0) + PWM_PB3 = 0; +*/ + } +} + + +/* +bool PWM_0000 (uint32_t ui32_Duty_x100) { +static uint32_t ui32_PWM_Base; + + if (ui32_PWM_Base >= 100) + ui32_PWM_Base = 0; + else + ui32_PWM_Base ++; + + if ( + (ui32_Duty_x100 > 0) && + (ui32_Duty_x100 <= 100) && + (ui32_PWM_Base <= ui32_Duty_x100) + ) + return (true); + else + return (false); +} + +void PWM____tScan (void) { + PWM = PWM_0000 (50); +} +*/
diff -r 12c555cade79 -r b9d23a2f390e main.h --- a/main.h Thu Jan 20 13:26:03 2022 +0000 +++ b/main.h Thu Feb 10 09:39:01 2022 +0000 @@ -12,4 +12,8 @@ Maintainer: Gregory Cristian, Gilbert Menth & Matthieu Verdy */ -void FactoryReset( void ); +//void FactoryReset (void); + +//void LCD____tScan (void); // LA: Ticked ... +//void Motion_tScan (void); // Ticked ... +//void PWM____tScan (void); // Ticked ...
diff -r 12c555cade79 -r b9d23a2f390e mbed.bld --- a/mbed.bld Thu Jan 20 13:26:03 2022 +0000 +++ b/mbed.bld Thu Feb 10 09:39:01 2022 +0000 @@ -1,1 +1,1 @@ -https://mbed.org/users/mbed_official/code/mbed/builds/25aea2a3f4e3 \ No newline at end of file +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file