Stabilus 322699 wDoublePID
Dependencies: mbed QEI PID DmTftLibraryEx
main.cpp@28:443c82750dd9, 2022-03-04 (annotated)
- Committer:
- lex9296
- Date:
- Fri Mar 04 14:03:57 2022 +0000
- Revision:
- 28:443c82750dd9
- Parent:
- 27:654100855f5c
- Child:
- 29:7ce8c5779f5e
04 Marzo 2022
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lex9296 | 28:443c82750dd9 | 1 | |
GregCr | 0:9c0917bfde97 | 2 | |
lex9296 | 23:b9d23a2f390e | 3 | //Warning: Incompatible redefinition of macro "MBED_RAM_SIZE" in "tmp/HU5Hqj", Line: 39, Col: 10 |
lex9296 | 23:b9d23a2f390e | 4 | #ifndef MBED_RAM_SIZE |
lex9296 | 23:b9d23a2f390e | 5 | #define MBED_RAM_SIZE 0x00018000 |
lex9296 | 23:b9d23a2f390e | 6 | #endif |
lex9296 | 23:b9d23a2f390e | 7 | |
lex9296 | 23:b9d23a2f390e | 8 | #include "QEI.h" |
lex9296 | 23:b9d23a2f390e | 9 | #include "SWPos.h" |
lex9296 | 23:b9d23a2f390e | 10 | |
GregCr | 0:9c0917bfde97 | 11 | #include "Timers.h" |
lex9296 | 23:b9d23a2f390e | 12 | //#include "Menu.h" |
GregCr | 0:9c0917bfde97 | 13 | #include "Eeprom.h" |
lex9296 | 23:b9d23a2f390e | 14 | //#include "main.h" |
lex9296 | 23:b9d23a2f390e | 15 | //#include "app_config.h" |
GregCr | 0:9c0917bfde97 | 16 | |
lex9296 | 27:654100855f5c | 17 | #define MAX_CHAR_PER_LINE 28 |
lex9296 | 27:654100855f5c | 18 | #define TEXT_ROW_SPACING 16 |
lex9296 | 27:654100855f5c | 19 | #define FONT_CHAR_WIDTH 8 |
lex9296 | 27:654100855f5c | 20 | #define FONT_CHAR_HEIGHT 16 |
lex9296 | 27:654100855f5c | 21 | |
lex9296 | 27:654100855f5c | 22 | //#include "mbed.h" |
lex9296 | 27:654100855f5c | 23 | #include "DisplayDriver.h" |
lex9296 | 27:654100855f5c | 24 | //#include "DmTftIli9341.h" |
lex9296 | 27:654100855f5c | 25 | //#include "DmTouch.h" |
lex9296 | 27:654100855f5c | 26 | //#include "DmTouchCalibration.h" |
lex9296 | 27:654100855f5c | 27 | |
lex9296 | 26:bfca0c471a87 | 28 | // LA: Theory of Operation |
lex9296 | 26:bfca0c471a87 | 29 | // =================== |
lex9296 | 26:bfca0c471a87 | 30 | // |
lex9296 | 26:bfca0c471a87 | 31 | // Il PWM funziona da sè in Interrupt |
lex9296 | 26:bfca0c471a87 | 32 | // Il QEI funziona da sè in Interrupt |
lex9296 | 26:bfca0c471a87 | 33 | // Se si creano dei Ticker (Che sono a loro volta interrupt(s)) è possibile che PWM e QEI perdano correlazione con l'HW. |
lex9296 | 26:bfca0c471a87 | 34 | // |
lex9296 | 26:bfca0c471a87 | 35 | // PQM |
lex9296 | 26:bfca0c471a87 | 36 | // |
lex9296 | 26:bfca0c471a87 | 37 | // Il rinfresco del Display e la gestione del motion vanno fatte il più frequentemente possibile ma fuori dal loop dei Ticker. |
lex9296 | 26:bfca0c471a87 | 38 | // Con qst versione (LA0005, che termina un FORK (il successivo è LA0010) quanto detto sopra è FUNZIONANTE. |
lex9296 | 26:bfca0c471a87 | 39 | // Questo messaggio è incluso nel "commitment" |
lex9296 | 26:bfca0c471a87 | 40 | |
GregCr | 0:9c0917bfde97 | 41 | /*! |
GregCr | 0:9c0917bfde97 | 42 | * \brief Define IO for Unused Pin |
GregCr | 0:9c0917bfde97 | 43 | */ |
lex9296 | 23:b9d23a2f390e | 44 | //DigitalOut F_CS (D6); // MBED description of pin |
lex9296 | 23:b9d23a2f390e | 45 | //DigitalOut SD_CS (D8); // MBED description of pin |
lex9296 | 23:b9d23a2f390e | 46 | |
lex9296 | 23:b9d23a2f390e | 47 | DigitalIn userButton (USER_BUTTON); |
mverdy | 15:ed7ed20b7114 | 48 | |
lex9296 | 23:b9d23a2f390e | 49 | AnalogIn adc_temp (ADC_TEMP); |
lex9296 | 23:b9d23a2f390e | 50 | AnalogIn adc_vref (ADC_VREF); |
lex9296 | 23:b9d23a2f390e | 51 | AnalogIn adc_vbat (ADC_VBAT); |
GregCr | 0:9c0917bfde97 | 52 | |
lex9296 | 23:b9d23a2f390e | 53 | // PWM |
lex9296 | 23:b9d23a2f390e | 54 | // === |
lex9296 | 23:b9d23a2f390e | 55 | // |
lex9296 | 25:5fd2d69e2927 | 56 | PwmOut PWM_PB3(PWM_OUT); // LA: PWM_OUT = D3 = PB_3 |
mverdy | 14:ebd89dacc807 | 57 | |
lex9296 | 28:443c82750dd9 | 58 | // QEI |
lex9296 | 28:443c82750dd9 | 59 | // === |
lex9296 | 28:443c82750dd9 | 60 | // |
lex9296 | 28:443c82750dd9 | 61 | QEI Stabilus322699 (PA_1, PA_0, NC, 100, QEI::X4_ENCODING); |
lex9296 | 28:443c82750dd9 | 62 | |
lex9296 | 23:b9d23a2f390e | 63 | // Motion |
lex9296 | 23:b9d23a2f390e | 64 | // ====== |
lex9296 | 23:b9d23a2f390e | 65 | // |
lex9296 | 28:443c82750dd9 | 66 | //Ticker POS_MotionScan; // LA: Non uso un Ticker. Agisce sotto Interrupt e falsa la lettura QEI e la sincronicità del PWM |
lex9296 | 23:b9d23a2f390e | 67 | // |
lex9296 | 23:b9d23a2f390e | 68 | in_sPosizionatoreSW in_PosizionatoreSW; |
lex9296 | 23:b9d23a2f390e | 69 | out_sPosizionatoreSW out_PosizionatoreSW; |
GregCr | 0:9c0917bfde97 | 70 | |
lex9296 | 23:b9d23a2f390e | 71 | // LCD Display |
lex9296 | 23:b9d23a2f390e | 72 | // =========== |
lex9296 | 23:b9d23a2f390e | 73 | // |
lex9296 | 28:443c82750dd9 | 74 | //Ticker LCD_RefreshViews; // LA: Non uso un Ticker. Agisce sotto Interrupt e falsa la lettura QEI e la sincronicità del PWM |
mverdy | 15:ed7ed20b7114 | 75 | |
lex9296 | 22:12c555cade79 | 76 | void FactoryReset (void) { |
mverdy | 15:ed7ed20b7114 | 77 | EepromFactoryReset( ); |
mverdy | 15:ed7ed20b7114 | 78 | HAL_NVIC_SystemReset( ); |
mverdy | 15:ed7ed20b7114 | 79 | } |
lex9296 | 23:b9d23a2f390e | 80 | |
lex9296 | 23:b9d23a2f390e | 81 | // ======= |
lex9296 | 23:b9d23a2f390e | 82 | // ======= |
lex9296 | 23:b9d23a2f390e | 83 | // Main(s) |
lex9296 | 23:b9d23a2f390e | 84 | // ======= |
lex9296 | 23:b9d23a2f390e | 85 | // ======= |
lex9296 | 23:b9d23a2f390e | 86 | // |
lex9296 | 23:b9d23a2f390e | 87 | int main (void){ |
lex9296 | 28:443c82750dd9 | 88 | char StringText[MAX_CHAR_PER_LINE + 1]; // don't forget the /0 (end of string) |
lex9296 | 28:443c82750dd9 | 89 | //char StringText2[MAX_CHAR_PER_LINE + 1]; |
lex9296 | 28:443c82750dd9 | 90 | //char StringText3[MAX_CHAR_PER_LINE + 1]; |
lex9296 | 28:443c82750dd9 | 91 | |
lex9296 | 28:443c82750dd9 | 92 | //uint16_t ui16_TestColor = 0x0000; |
lex9296 | 28:443c82750dd9 | 93 | //uint16_t ui16_TestStep = 0x0000; |
lex9296 | 28:443c82750dd9 | 94 | // |
lex9296 | 28:443c82750dd9 | 95 | //uint16_t ui16_R = 0x00; |
lex9296 | 28:443c82750dd9 | 96 | //uint16_t ui16_G = 0x00; |
lex9296 | 28:443c82750dd9 | 97 | //uint16_t ui16_B = 0x00; |
lex9296 | 28:443c82750dd9 | 98 | |
lex9296 | 28:443c82750dd9 | 99 | uint32_t ui32_PreCallms; |
lex9296 | 28:443c82750dd9 | 100 | uint32_t ui32_PostCallms; |
lex9296 | 28:443c82750dd9 | 101 | uint32_t ui32_Samplems; |
lex9296 | 28:443c82750dd9 | 102 | |
lex9296 | 23:b9d23a2f390e | 103 | |
lex9296 | 23:b9d23a2f390e | 104 | EepromInit(); // LA: Inizializza la EEProm |
lex9296 | 23:b9d23a2f390e | 105 | TimersInit(); // LA: Parte il Timer a 1ms |
lex9296 | 23:b9d23a2f390e | 106 | |
lex9296 | 23:b9d23a2f390e | 107 | // LA: FactoryReset se "userButton" premuto all'avvio |
lex9296 | 23:b9d23a2f390e | 108 | // |
lex9296 | 23:b9d23a2f390e | 109 | if (userButton == 0) { |
lex9296 | 23:b9d23a2f390e | 110 | FactoryReset(); |
lex9296 | 23:b9d23a2f390e | 111 | } |
lex9296 | 28:443c82750dd9 | 112 | DisplayDriverInit(); |
lex9296 | 23:b9d23a2f390e | 113 | |
lex9296 | 28:443c82750dd9 | 114 | PWM_PB3.period_us(100); // LA: Avvia il PWM con TimeBase 100us |
lex9296 | 28:443c82750dd9 | 115 | PWM_PB3.pulsewidth_us(0); // 0.. 100us -> 0.. 100%, Set to ZERO |
lex9296 | 23:b9d23a2f390e | 116 | |
lex9296 | 23:b9d23a2f390e | 117 | // LA: Motion (1st) Setup |
lex9296 | 23:b9d23a2f390e | 118 | // |
lex9296 | 28:443c82750dd9 | 119 | in_PosizionatoreSW.b_AxisPowered = true; |
lex9296 | 28:443c82750dd9 | 120 | in_PosizionatoreSW.b_ACPos_Homed = true; |
lex9296 | 23:b9d23a2f390e | 121 | in_PosizionatoreSW.i32_Max_Speed = 1024; // [ui] |
lex9296 | 23:b9d23a2f390e | 122 | in_PosizionatoreSW.i32_ZeroSpeed = 0; // |
lex9296 | 23:b9d23a2f390e | 123 | |
lex9296 | 23:b9d23a2f390e | 124 | in_PosizionatoreSW.b_JogMode = false; |
lex9296 | 23:b9d23a2f390e | 125 | in_PosizionatoreSW.b_JogFW = false; |
lex9296 | 23:b9d23a2f390e | 126 | in_PosizionatoreSW.b_JogBW = false; |
lex9296 | 23:b9d23a2f390e | 127 | in_PosizionatoreSW.i32_JogAccel_ms = 500; // [ms] |
lex9296 | 23:b9d23a2f390e | 128 | in_PosizionatoreSW.i32_JogDecel_ms = 250; // |
lex9296 | 23:b9d23a2f390e | 129 | // |
lex9296 | 23:b9d23a2f390e | 130 | in_PosizionatoreSW.f_JogSpeed_x100_FW = 25.0; // % of "i32_Max_Speed" |
lex9296 | 23:b9d23a2f390e | 131 | in_PosizionatoreSW.f_JogSpeed_x100_BW = 25.0; // |
lex9296 | 23:b9d23a2f390e | 132 | |
lex9296 | 28:443c82750dd9 | 133 | in_PosizionatoreSW.b_ServoLock = true; |
lex9296 | 23:b9d23a2f390e | 134 | in_PosizionatoreSW.rtServoLock_Q = false; |
lex9296 | 23:b9d23a2f390e | 135 | // |
lex9296 | 28:443c82750dd9 | 136 | in_PosizionatoreSW.i64_TargetPosition = 1000; // [ui] |
lex9296 | 28:443c82750dd9 | 137 | in_PosizionatoreSW.i64_ActualPosition = 200; // |
lex9296 | 28:443c82750dd9 | 138 | in_PosizionatoreSW.i64_AccelerationWindow = 50; // LA: Spazio concesso all'accelerazione. |
lex9296 | 28:443c82750dd9 | 139 | in_PosizionatoreSW.i64_DecelerationWindow = 50; // Spazio concesso alla decelerazione, è prioritario rispetto all'accelerazione. |
lex9296 | 28:443c82750dd9 | 140 | in_PosizionatoreSW.i64_diToleranceWindow = 10; // Finestra di Tolleranza |
lex9296 | 23:b9d23a2f390e | 141 | // |
lex9296 | 23:b9d23a2f390e | 142 | in_PosizionatoreSW.f_MaximumSpeed_x100_FW = 25.0; // % of "i32_Max_Speed" |
lex9296 | 23:b9d23a2f390e | 143 | in_PosizionatoreSW.f_MaximumSpeed_x100_BW = 25.0; // |
lex9296 | 23:b9d23a2f390e | 144 | in_PosizionatoreSW.f_ServoLockSpeed_x100_FW = 5.0; // |
lex9296 | 23:b9d23a2f390e | 145 | in_PosizionatoreSW.f_ServoLockSpeed_x100_BW = 5.0; // |
lex9296 | 23:b9d23a2f390e | 146 | |
lex9296 | 28:443c82750dd9 | 147 | // LA: Color RGB Component(s) |
lex9296 | 28:443c82750dd9 | 148 | // ====================== |
lex9296 | 28:443c82750dd9 | 149 | // |
lex9296 | 28:443c82750dd9 | 150 | // RED 0000 1000 0000 0000 min 0x0800 02048 |
lex9296 | 28:443c82750dd9 | 151 | // 1111 1000 0000 0000 max 0xf800 63488 |
lex9296 | 28:443c82750dd9 | 152 | // |
lex9296 | 28:443c82750dd9 | 153 | // GREEN 0000 0000 0010 0000 min 0x0020 00032 |
lex9296 | 28:443c82750dd9 | 154 | // 0000 0111 1110 0000 max 0x07e0 02016 |
lex9296 | 28:443c82750dd9 | 155 | // |
lex9296 | 28:443c82750dd9 | 156 | // BLUE 0000 0000 0000 0001 min 0x0001 00001 |
lex9296 | 28:443c82750dd9 | 157 | // 0000 0000 0001 1111 max 0x001f 00031 |
lex9296 | 28:443c82750dd9 | 158 | // |
lex9296 | 28:443c82750dd9 | 159 | // La componente ROSSA ha 5 bit di escursione (0.. 31), |
lex9296 | 28:443c82750dd9 | 160 | // La componente VERDE ha 6 bit di escursione (0.. 63), |
lex9296 | 28:443c82750dd9 | 161 | // La componente BLU ha 5 bit di escursione (0.. 31), |
lex9296 | 28:443c82750dd9 | 162 | // |
lex9296 | 28:443c82750dd9 | 163 | // Le componenti RGB di "Color" sono quindi scritte negli appropriati registri come segue: |
lex9296 | 28:443c82750dd9 | 164 | // |
lex9296 | 28:443c82750dd9 | 165 | // writeReg(RED, (Color & 0xf800) >> 11); |
lex9296 | 28:443c82750dd9 | 166 | // writeReg(GREEN, (Color & 0x07e0) >> 5); |
lex9296 | 28:443c82750dd9 | 167 | // writeReg(BLUE, (Color & 0x001f)); |
lex9296 | 28:443c82750dd9 | 168 | // |
lex9296 | 28:443c82750dd9 | 169 | LCM_SetTextColor(Scale2RGBColor (31, 31, 31), Scale2RGBColor (0, 0, 0)); // LA: Black on White |
lex9296 | 28:443c82750dd9 | 170 | LCM_ClearScreen (Scale2RGBColor (31, 31, 31)); |
lex9296 | 23:b9d23a2f390e | 171 | |
lex9296 | 28:443c82750dd9 | 172 | // ui16_TestColor = Scale2RGBColor (ui16_R, ui16_G, ui16_B); |
lex9296 | 28:443c82750dd9 | 173 | // LCM_SetTextColor ( |
lex9296 | 28:443c82750dd9 | 174 | // Scale2RGBColor (0, 0, 0), |
lex9296 | 28:443c82750dd9 | 175 | // Scale2RGBColor (31, 31, 31) |
lex9296 | 28:443c82750dd9 | 176 | // ); |
lex9296 | 28:443c82750dd9 | 177 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 0), "You Start Me Up ..."); |
lex9296 | 28:443c82750dd9 | 178 | |
lex9296 | 28:443c82750dd9 | 179 | while (1) { |
lex9296 | 28:443c82750dd9 | 180 | static int32_t Pulses_Prec; |
lex9296 | 28:443c82750dd9 | 181 | static uint32_t ms_0002_prec; |
lex9296 | 28:443c82750dd9 | 182 | static uint32_t ms_0003_prec; |
lex9296 | 28:443c82750dd9 | 183 | int32_t i32_Pulses; |
lex9296 | 23:b9d23a2f390e | 184 | |
lex9296 | 28:443c82750dd9 | 185 | float f_ai0000_Aux; |
lex9296 | 28:443c82750dd9 | 186 | float f_ai0000_prec; |
lex9296 | 28:443c82750dd9 | 187 | float f_ai0001_prec; |
lex9296 | 28:443c82750dd9 | 188 | float f_ai0002_prec; |
lex9296 | 28:443c82750dd9 | 189 | |
lex9296 | 28:443c82750dd9 | 190 | i32_Pulses = Stabilus322699.getPulses(); |
lex9296 | 28:443c82750dd9 | 191 | PWM_PB3.pulsewidth_us(((float)i32_Pulses/ (float)5000.0)* (float)100.0); // 0.. 100us -> 0.. 100% |
lex9296 | 28:443c82750dd9 | 192 | |
lex9296 | 28:443c82750dd9 | 193 | in_PosizionatoreSW.i64_ActualPosition = (int64_t) i32_Pulses; // |
lex9296 | 27:654100855f5c | 194 | |
lex9296 | 28:443c82750dd9 | 195 | ui32_PreCallms = TimersTimerValue(); // Freezes the Actual Sample. |
lex9296 | 28:443c82750dd9 | 196 | PosizionatoreSW (in_PosizionatoreSW, out_PosizionatoreSW); |
lex9296 | 28:443c82750dd9 | 197 | ui32_PostCallms = TimersTimerValue(); |
lex9296 | 28:443c82750dd9 | 198 | // |
lex9296 | 28:443c82750dd9 | 199 | if (ui32_PostCallms >= ui32_PreCallms) |
lex9296 | 28:443c82750dd9 | 200 | ui32_Samplems = ui32_PostCallms- ui32_PreCallms; // Result => Actual - Previous |
lex9296 | 28:443c82750dd9 | 201 | else |
lex9296 | 28:443c82750dd9 | 202 | ui32_Samplems = ui32_PostCallms+ (0x7fffffff- ui32_PreCallms); // Result => Actual+ (Rollover- Previous) |
lex9296 | 28:443c82750dd9 | 203 | |
lex9296 | 27:654100855f5c | 204 | |
lex9296 | 28:443c82750dd9 | 205 | // LA: Wedge 4 LCDRefresh |
lex9296 | 28:443c82750dd9 | 206 | if ( |
lex9296 | 28:443c82750dd9 | 207 | (i32_Pulses != Pulses_Prec) |
lex9296 | 28:443c82750dd9 | 208 | ) { |
lex9296 | 28:443c82750dd9 | 209 | sprintf (StringText, |
lex9296 | 28:443c82750dd9 | 210 | "Pulses: %d ", i32_Pulses); |
lex9296 | 28:443c82750dd9 | 211 | LCM_SetTextColor (Scale2RGBColor (0, 0, 31), Scale2RGBColor (31, 31, 0)); |
lex9296 | 28:443c82750dd9 | 212 | LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 1), StringText); |
lex9296 | 28:443c82750dd9 | 213 | } |
lex9296 | 28:443c82750dd9 | 214 | |
lex9296 | 28:443c82750dd9 | 215 | // if (out_PosizionatoreSW.ui32_PassedActual_ms != ms_0003_prec) { |
lex9296 | 28:443c82750dd9 | 216 | if (ui32_Samplems != ms_0003_prec) { |
lex9296 | 28:443c82750dd9 | 217 | sprintf (StringText, |
lex9296 | 28:443c82750dd9 | 218 | // "PassedActual_ms: %d ", out_PosizionatoreSW.ui32_PassedActual_ms); |
lex9296 | 28:443c82750dd9 | 219 | "PassedActual_ms: %d ", ui32_Samplems); |
lex9296 | 28:443c82750dd9 | 220 | LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31)); |
lex9296 | 28:443c82750dd9 | 221 | LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 2), StringText); |
lex9296 | 28:443c82750dd9 | 222 | // ms_0003_prec = out_PosizionatoreSW.ui32_PassedActual_ms; |
lex9296 | 28:443c82750dd9 | 223 | ms_0003_prec = ui32_Samplems; |
lex9296 | 28:443c82750dd9 | 224 | } |
lex9296 | 28:443c82750dd9 | 225 | |
lex9296 | 28:443c82750dd9 | 226 | if (out_PosizionatoreSW.i32_ATVSpeed != ms_0002_prec) { |
lex9296 | 28:443c82750dd9 | 227 | sprintf (StringText, |
lex9296 | 28:443c82750dd9 | 228 | "Speed[ui]: %d ", out_PosizionatoreSW.i32_ATVSpeed); |
lex9296 | 28:443c82750dd9 | 229 | LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31)); |
lex9296 | 28:443c82750dd9 | 230 | LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 3), StringText); |
lex9296 | 28:443c82750dd9 | 231 | ms_0002_prec = out_PosizionatoreSW.i32_ATVSpeed; |
lex9296 | 28:443c82750dd9 | 232 | } |
lex9296 | 27:654100855f5c | 233 | |
lex9296 | 28:443c82750dd9 | 234 | f_ai0000_Aux = adc_temp.read(); |
lex9296 | 28:443c82750dd9 | 235 | if (f_ai0000_Aux != f_ai0000_prec) { |
lex9296 | 28:443c82750dd9 | 236 | sprintf (StringText, |
lex9296 | 28:443c82750dd9 | 237 | // "ADC Temp = %f\n", (f_ai0000_Aux* 100)); |
lex9296 | 28:443c82750dd9 | 238 | "ADC Temp = %f ", (f_ai0000_Aux* 100)); |
lex9296 | 28:443c82750dd9 | 239 | LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31)); |
lex9296 | 28:443c82750dd9 | 240 | LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 4), StringText); |
lex9296 | 28:443c82750dd9 | 241 | f_ai0000_prec = f_ai0000_Aux; |
lex9296 | 28:443c82750dd9 | 242 | } |
lex9296 | 27:654100855f5c | 243 | |
lex9296 | 28:443c82750dd9 | 244 | f_ai0000_Aux = adc_vbat.read(); |
lex9296 | 28:443c82750dd9 | 245 | if (f_ai0000_Aux != f_ai0001_prec) { |
lex9296 | 28:443c82750dd9 | 246 | sprintf (StringText, |
lex9296 | 28:443c82750dd9 | 247 | // "ADC VBat = %f\n", (f_ai0000_Aux* 100)); |
lex9296 | 28:443c82750dd9 | 248 | "ADC VBat = %f ", (f_ai0000_Aux)); |
lex9296 | 28:443c82750dd9 | 249 | LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31)); |
lex9296 | 28:443c82750dd9 | 250 | LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 5), StringText); |
lex9296 | 28:443c82750dd9 | 251 | f_ai0001_prec = f_ai0000_Aux; |
lex9296 | 28:443c82750dd9 | 252 | } |
lex9296 | 27:654100855f5c | 253 | |
lex9296 | 28:443c82750dd9 | 254 | f_ai0000_Aux = adc_vref.read(); |
lex9296 | 28:443c82750dd9 | 255 | if (f_ai0000_Aux != f_ai0002_prec) { |
lex9296 | 28:443c82750dd9 | 256 | sprintf (StringText, |
lex9296 | 28:443c82750dd9 | 257 | // "ADC VRef = %f\n", (f_ai0000_Aux* 100)); |
lex9296 | 28:443c82750dd9 | 258 | "ADC VRef = %f ", (f_ai0000_Aux)); |
lex9296 | 28:443c82750dd9 | 259 | LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31)); |
lex9296 | 28:443c82750dd9 | 260 | LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 6), StringText); |
lex9296 | 28:443c82750dd9 | 261 | f_ai0002_prec = f_ai0000_Aux; |
lex9296 | 28:443c82750dd9 | 262 | } |
lex9296 | 28:443c82750dd9 | 263 | } |
lex9296 | 28:443c82750dd9 | 264 | } |
lex9296 | 28:443c82750dd9 | 265 | |
lex9296 | 28:443c82750dd9 | 266 | /* |
lex9296 | 27:654100855f5c | 267 | while (ui16_TestStep < 32) { |
lex9296 | 27:654100855f5c | 268 | |
lex9296 | 27:654100855f5c | 269 | ui16_TestColor = Scale2RGBColor (ui16_R, ui16_G, ui16_B); |
lex9296 | 27:654100855f5c | 270 | LCM_ClearScreen (ui16_TestColor); |
lex9296 | 27:654100855f5c | 271 | LCM_SetTextColor(ui16_TestColor, (0xffff- ui16_TestColor)); |
lex9296 | 27:654100855f5c | 272 | sprintf (StringText, |
lex9296 | 27:654100855f5c | 273 | "Color: %04x %04x ", ui16_TestColor, ui16_TestStep); |
lex9296 | 27:654100855f5c | 274 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), StringText); |
lex9296 | 27:654100855f5c | 275 | sprintf (StringText, |
lex9296 | 27:654100855f5c | 276 | "R:%02x G:%02x B:%02x ", ui16_R, ui16_G, ui16_B); |
lex9296 | 27:654100855f5c | 277 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 5), StringText); |
lex9296 | 27:654100855f5c | 278 | // delay (500); |
lex9296 | 27:654100855f5c | 279 | |
lex9296 | 27:654100855f5c | 280 | ui16_R++; |
lex9296 | 27:654100855f5c | 281 | ui16_G++; |
lex9296 | 27:654100855f5c | 282 | ui16_B++; |
lex9296 | 27:654100855f5c | 283 | // ui16_TestColor += 0x0841; |
lex9296 | 27:654100855f5c | 284 | ui16_TestStep ++; |
lex9296 | 27:654100855f5c | 285 | } |
lex9296 | 27:654100855f5c | 286 | delay (2500); |
lex9296 | 28:443c82750dd9 | 287 | */ |