All the previous but the PID

Dependencies:   mbed QEI PID DmTftLibraryEx

Committer:
lex9296
Date:
Fri Mar 04 15:31:53 2022 +0000
Revision:
29:7ce8c5779f5e
Parent:
28:443c82750dd9
Child:
30:e45282a70a4d
4 Marzo 2022, Stage A cleared.; Il vettore viene popolato correttamente (1 sample ogni ms); Resta solo da plottare

Who changed what in which revision?

UserRevisionLine numberNew 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 29:7ce8c5779f5e 28 int32_t i32_Pulses;
lex9296 29:7ce8c5779f5e 29 //
lex9296 29:7ce8c5779f5e 30 static void SampleAndStore (void);
lex9296 29:7ce8c5779f5e 31 Ticker SampleTimer; // LA: To Sample 1AI any ms
lex9296 29:7ce8c5779f5e 32 float af_PlotSamples[240]; // LA: "Horiz" Plot Array
lex9296 29:7ce8c5779f5e 33
lex9296 26:bfca0c471a87 34 // LA: Theory of Operation
lex9296 26:bfca0c471a87 35 // ===================
lex9296 26:bfca0c471a87 36 //
lex9296 26:bfca0c471a87 37 // Il PWM funziona da sè in Interrupt
lex9296 26:bfca0c471a87 38 // Il QEI funziona da sè in Interrupt
lex9296 26:bfca0c471a87 39 // 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 40 //
lex9296 26:bfca0c471a87 41 // PQM
lex9296 26:bfca0c471a87 42 //
lex9296 26:bfca0c471a87 43 // Il rinfresco del Display e la gestione del motion vanno fatte il più frequentemente possibile ma fuori dal loop dei Ticker.
lex9296 26:bfca0c471a87 44 // Con qst versione (LA0005, che termina un FORK (il successivo è LA0010) quanto detto sopra è FUNZIONANTE.
lex9296 26:bfca0c471a87 45 // Questo messaggio è incluso nel "commitment"
lex9296 26:bfca0c471a87 46
GregCr 0:9c0917bfde97 47 /*!
GregCr 0:9c0917bfde97 48 * \brief Define IO for Unused Pin
GregCr 0:9c0917bfde97 49 */
lex9296 23:b9d23a2f390e 50 //DigitalOut F_CS (D6); // MBED description of pin
lex9296 23:b9d23a2f390e 51 //DigitalOut SD_CS (D8); // MBED description of pin
lex9296 23:b9d23a2f390e 52
lex9296 23:b9d23a2f390e 53 DigitalIn userButton (USER_BUTTON);
mverdy 15:ed7ed20b7114 54
lex9296 23:b9d23a2f390e 55 AnalogIn adc_temp (ADC_TEMP);
lex9296 23:b9d23a2f390e 56 AnalogIn adc_vref (ADC_VREF);
lex9296 23:b9d23a2f390e 57 AnalogIn adc_vbat (ADC_VBAT);
GregCr 0:9c0917bfde97 58
lex9296 29:7ce8c5779f5e 59 AnalogIn ADC12_IN9 (PA_4); // STM32 PA4
lex9296 29:7ce8c5779f5e 60 AnalogIn ADC12_IN15 (PB_0); // STM32 PB0
lex9296 29:7ce8c5779f5e 61
lex9296 23:b9d23a2f390e 62 // PWM
lex9296 23:b9d23a2f390e 63 // ===
lex9296 23:b9d23a2f390e 64 //
lex9296 25:5fd2d69e2927 65 PwmOut PWM_PB3(PWM_OUT); // LA: PWM_OUT = D3 = PB_3
mverdy 14:ebd89dacc807 66
lex9296 28:443c82750dd9 67 // QEI
lex9296 28:443c82750dd9 68 // ===
lex9296 28:443c82750dd9 69 //
lex9296 28:443c82750dd9 70 QEI Stabilus322699 (PA_1, PA_0, NC, 100, QEI::X4_ENCODING);
lex9296 28:443c82750dd9 71
lex9296 23:b9d23a2f390e 72 // Motion
lex9296 23:b9d23a2f390e 73 // ======
lex9296 23:b9d23a2f390e 74 //
lex9296 28:443c82750dd9 75 //Ticker POS_MotionScan; // LA: Non uso un Ticker. Agisce sotto Interrupt e falsa la lettura QEI e la sincronicità del PWM
lex9296 23:b9d23a2f390e 76 //
lex9296 23:b9d23a2f390e 77 in_sPosizionatoreSW in_PosizionatoreSW;
lex9296 23:b9d23a2f390e 78 out_sPosizionatoreSW out_PosizionatoreSW;
GregCr 0:9c0917bfde97 79
lex9296 23:b9d23a2f390e 80 // LCD Display
lex9296 23:b9d23a2f390e 81 // ===========
lex9296 23:b9d23a2f390e 82 //
lex9296 28:443c82750dd9 83 //Ticker LCD_RefreshViews; // LA: Non uso un Ticker. Agisce sotto Interrupt e falsa la lettura QEI e la sincronicità del PWM
mverdy 15:ed7ed20b7114 84
lex9296 22:12c555cade79 85 void FactoryReset (void) {
mverdy 15:ed7ed20b7114 86 EepromFactoryReset( );
mverdy 15:ed7ed20b7114 87 HAL_NVIC_SystemReset( );
mverdy 15:ed7ed20b7114 88 }
lex9296 23:b9d23a2f390e 89
lex9296 23:b9d23a2f390e 90 // =======
lex9296 23:b9d23a2f390e 91 // =======
lex9296 23:b9d23a2f390e 92 // Main(s)
lex9296 23:b9d23a2f390e 93 // =======
lex9296 23:b9d23a2f390e 94 // =======
lex9296 23:b9d23a2f390e 95 //
lex9296 23:b9d23a2f390e 96 int main (void){
lex9296 28:443c82750dd9 97 char StringText[MAX_CHAR_PER_LINE + 1]; // don't forget the /0 (end of string)
lex9296 28:443c82750dd9 98 //char StringText2[MAX_CHAR_PER_LINE + 1];
lex9296 28:443c82750dd9 99 //char StringText3[MAX_CHAR_PER_LINE + 1];
lex9296 28:443c82750dd9 100
lex9296 28:443c82750dd9 101 //uint16_t ui16_TestColor = 0x0000;
lex9296 28:443c82750dd9 102 //uint16_t ui16_TestStep = 0x0000;
lex9296 28:443c82750dd9 103 //
lex9296 28:443c82750dd9 104 //uint16_t ui16_R = 0x00;
lex9296 28:443c82750dd9 105 //uint16_t ui16_G = 0x00;
lex9296 28:443c82750dd9 106 //uint16_t ui16_B = 0x00;
lex9296 28:443c82750dd9 107
lex9296 28:443c82750dd9 108 uint32_t ui32_PreCallms;
lex9296 28:443c82750dd9 109 uint32_t ui32_PostCallms;
lex9296 28:443c82750dd9 110 uint32_t ui32_Samplems;
lex9296 28:443c82750dd9 111
lex9296 23:b9d23a2f390e 112 EepromInit(); // LA: Inizializza la EEProm
lex9296 23:b9d23a2f390e 113 TimersInit(); // LA: Parte il Timer a 1ms
lex9296 23:b9d23a2f390e 114
lex9296 29:7ce8c5779f5e 115 SampleTimer.attach_us( &SampleAndStore, 1000 );
lex9296 29:7ce8c5779f5e 116
lex9296 23:b9d23a2f390e 117 // LA: FactoryReset se "userButton" premuto all'avvio
lex9296 23:b9d23a2f390e 118 //
lex9296 23:b9d23a2f390e 119 if (userButton == 0) {
lex9296 23:b9d23a2f390e 120 FactoryReset();
lex9296 23:b9d23a2f390e 121 }
lex9296 28:443c82750dd9 122 DisplayDriverInit();
lex9296 23:b9d23a2f390e 123
lex9296 28:443c82750dd9 124 PWM_PB3.period_us(100); // LA: Avvia il PWM con TimeBase 100us
lex9296 28:443c82750dd9 125 PWM_PB3.pulsewidth_us(0); // 0.. 100us -> 0.. 100%, Set to ZERO
lex9296 23:b9d23a2f390e 126
lex9296 23:b9d23a2f390e 127 // LA: Motion (1st) Setup
lex9296 23:b9d23a2f390e 128 //
lex9296 28:443c82750dd9 129 in_PosizionatoreSW.b_AxisPowered = true;
lex9296 28:443c82750dd9 130 in_PosizionatoreSW.b_ACPos_Homed = true;
lex9296 23:b9d23a2f390e 131 in_PosizionatoreSW.i32_Max_Speed = 1024; // [ui]
lex9296 23:b9d23a2f390e 132 in_PosizionatoreSW.i32_ZeroSpeed = 0; //
lex9296 23:b9d23a2f390e 133
lex9296 23:b9d23a2f390e 134 in_PosizionatoreSW.b_JogMode = false;
lex9296 23:b9d23a2f390e 135 in_PosizionatoreSW.b_JogFW = false;
lex9296 23:b9d23a2f390e 136 in_PosizionatoreSW.b_JogBW = false;
lex9296 23:b9d23a2f390e 137 in_PosizionatoreSW.i32_JogAccel_ms = 500; // [ms]
lex9296 23:b9d23a2f390e 138 in_PosizionatoreSW.i32_JogDecel_ms = 250; //
lex9296 23:b9d23a2f390e 139 //
lex9296 23:b9d23a2f390e 140 in_PosizionatoreSW.f_JogSpeed_x100_FW = 25.0; // % of "i32_Max_Speed"
lex9296 23:b9d23a2f390e 141 in_PosizionatoreSW.f_JogSpeed_x100_BW = 25.0; //
lex9296 23:b9d23a2f390e 142
lex9296 28:443c82750dd9 143 in_PosizionatoreSW.b_ServoLock = true;
lex9296 23:b9d23a2f390e 144 in_PosizionatoreSW.rtServoLock_Q = false;
lex9296 23:b9d23a2f390e 145 //
lex9296 28:443c82750dd9 146 in_PosizionatoreSW.i64_TargetPosition = 1000; // [ui]
lex9296 28:443c82750dd9 147 in_PosizionatoreSW.i64_ActualPosition = 200; //
lex9296 28:443c82750dd9 148 in_PosizionatoreSW.i64_AccelerationWindow = 50; // LA: Spazio concesso all'accelerazione.
lex9296 28:443c82750dd9 149 in_PosizionatoreSW.i64_DecelerationWindow = 50; // Spazio concesso alla decelerazione, è prioritario rispetto all'accelerazione.
lex9296 28:443c82750dd9 150 in_PosizionatoreSW.i64_diToleranceWindow = 10; // Finestra di Tolleranza
lex9296 23:b9d23a2f390e 151 //
lex9296 23:b9d23a2f390e 152 in_PosizionatoreSW.f_MaximumSpeed_x100_FW = 25.0; // % of "i32_Max_Speed"
lex9296 23:b9d23a2f390e 153 in_PosizionatoreSW.f_MaximumSpeed_x100_BW = 25.0; //
lex9296 23:b9d23a2f390e 154 in_PosizionatoreSW.f_ServoLockSpeed_x100_FW = 5.0; //
lex9296 23:b9d23a2f390e 155 in_PosizionatoreSW.f_ServoLockSpeed_x100_BW = 5.0; //
lex9296 23:b9d23a2f390e 156
lex9296 28:443c82750dd9 157 // LA: Color RGB Component(s)
lex9296 28:443c82750dd9 158 // ======================
lex9296 28:443c82750dd9 159 //
lex9296 28:443c82750dd9 160 // RED 0000 1000 0000 0000 min 0x0800 02048
lex9296 28:443c82750dd9 161 // 1111 1000 0000 0000 max 0xf800 63488
lex9296 28:443c82750dd9 162 //
lex9296 28:443c82750dd9 163 // GREEN 0000 0000 0010 0000 min 0x0020 00032
lex9296 28:443c82750dd9 164 // 0000 0111 1110 0000 max 0x07e0 02016
lex9296 28:443c82750dd9 165 //
lex9296 28:443c82750dd9 166 // BLUE 0000 0000 0000 0001 min 0x0001 00001
lex9296 28:443c82750dd9 167 // 0000 0000 0001 1111 max 0x001f 00031
lex9296 28:443c82750dd9 168 //
lex9296 28:443c82750dd9 169 // La componente ROSSA ha 5 bit di escursione (0.. 31),
lex9296 28:443c82750dd9 170 // La componente VERDE ha 6 bit di escursione (0.. 63),
lex9296 28:443c82750dd9 171 // La componente BLU ha 5 bit di escursione (0.. 31),
lex9296 28:443c82750dd9 172 //
lex9296 28:443c82750dd9 173 // Le componenti RGB di "Color" sono quindi scritte negli appropriati registri come segue:
lex9296 28:443c82750dd9 174 //
lex9296 28:443c82750dd9 175 // writeReg(RED, (Color & 0xf800) >> 11);
lex9296 28:443c82750dd9 176 // writeReg(GREEN, (Color & 0x07e0) >> 5);
lex9296 28:443c82750dd9 177 // writeReg(BLUE, (Color & 0x001f));
lex9296 28:443c82750dd9 178 //
lex9296 28:443c82750dd9 179 LCM_SetTextColor(Scale2RGBColor (31, 31, 31), Scale2RGBColor (0, 0, 0)); // LA: Black on White
lex9296 28:443c82750dd9 180 LCM_ClearScreen (Scale2RGBColor (31, 31, 31));
lex9296 23:b9d23a2f390e 181
lex9296 28:443c82750dd9 182 // ui16_TestColor = Scale2RGBColor (ui16_R, ui16_G, ui16_B);
lex9296 28:443c82750dd9 183 // LCM_SetTextColor (
lex9296 28:443c82750dd9 184 // Scale2RGBColor (0, 0, 0),
lex9296 28:443c82750dd9 185 // Scale2RGBColor (31, 31, 31)
lex9296 28:443c82750dd9 186 // );
lex9296 29:7ce8c5779f5e 187 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 0), "You Start Me Up ...");
lex9296 28:443c82750dd9 188
lex9296 28:443c82750dd9 189 while (1) {
lex9296 28:443c82750dd9 190 static int32_t Pulses_Prec;
lex9296 28:443c82750dd9 191 static uint32_t ms_0002_prec;
lex9296 28:443c82750dd9 192 static uint32_t ms_0003_prec;
lex9296 23:b9d23a2f390e 193
lex9296 28:443c82750dd9 194 float f_ai0000_Aux;
lex9296 29:7ce8c5779f5e 195 //
lex9296 28:443c82750dd9 196 float f_ai0000_prec;
lex9296 28:443c82750dd9 197 float f_ai0001_prec;
lex9296 28:443c82750dd9 198 float f_ai0002_prec;
lex9296 29:7ce8c5779f5e 199 float f_ai0003_prec;
lex9296 29:7ce8c5779f5e 200 float f_ai0004_prec;
lex9296 28:443c82750dd9 201
lex9296 29:7ce8c5779f5e 202 /*
lex9296 28:443c82750dd9 203 i32_Pulses = Stabilus322699.getPulses();
lex9296 28:443c82750dd9 204 PWM_PB3.pulsewidth_us(((float)i32_Pulses/ (float)5000.0)* (float)100.0); // 0.. 100us -> 0.. 100%
lex9296 28:443c82750dd9 205
lex9296 28:443c82750dd9 206 in_PosizionatoreSW.i64_ActualPosition = (int64_t) i32_Pulses; //
lex9296 27:654100855f5c 207
lex9296 28:443c82750dd9 208 ui32_PreCallms = TimersTimerValue(); // Freezes the Actual Sample.
lex9296 28:443c82750dd9 209 PosizionatoreSW (in_PosizionatoreSW, out_PosizionatoreSW);
lex9296 28:443c82750dd9 210 ui32_PostCallms = TimersTimerValue();
lex9296 28:443c82750dd9 211 //
lex9296 28:443c82750dd9 212 if (ui32_PostCallms >= ui32_PreCallms)
lex9296 28:443c82750dd9 213 ui32_Samplems = ui32_PostCallms- ui32_PreCallms; // Result => Actual - Previous
lex9296 28:443c82750dd9 214 else
lex9296 28:443c82750dd9 215 ui32_Samplems = ui32_PostCallms+ (0x7fffffff- ui32_PreCallms); // Result => Actual+ (Rollover- Previous)
lex9296 29:7ce8c5779f5e 216 */
lex9296 29:7ce8c5779f5e 217 // Override
lex9296 29:7ce8c5779f5e 218 //
lex9296 29:7ce8c5779f5e 219
lex9296 27:654100855f5c 220
lex9296 28:443c82750dd9 221 // LA: Wedge 4 LCDRefresh
lex9296 28:443c82750dd9 222 if (
lex9296 28:443c82750dd9 223 (i32_Pulses != Pulses_Prec)
lex9296 28:443c82750dd9 224 ) {
lex9296 28:443c82750dd9 225 sprintf (StringText,
lex9296 28:443c82750dd9 226 "Pulses: %d ", i32_Pulses);
lex9296 28:443c82750dd9 227 LCM_SetTextColor (Scale2RGBColor (0, 0, 31), Scale2RGBColor (31, 31, 0));
lex9296 28:443c82750dd9 228 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 1), StringText);
lex9296 28:443c82750dd9 229 }
lex9296 28:443c82750dd9 230
lex9296 28:443c82750dd9 231 // if (out_PosizionatoreSW.ui32_PassedActual_ms != ms_0003_prec) {
lex9296 28:443c82750dd9 232 if (ui32_Samplems != ms_0003_prec) {
lex9296 28:443c82750dd9 233 sprintf (StringText,
lex9296 28:443c82750dd9 234 // "PassedActual_ms: %d ", out_PosizionatoreSW.ui32_PassedActual_ms);
lex9296 28:443c82750dd9 235 "PassedActual_ms: %d ", ui32_Samplems);
lex9296 28:443c82750dd9 236 LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31));
lex9296 28:443c82750dd9 237 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 2), StringText);
lex9296 28:443c82750dd9 238 // ms_0003_prec = out_PosizionatoreSW.ui32_PassedActual_ms;
lex9296 28:443c82750dd9 239 ms_0003_prec = ui32_Samplems;
lex9296 28:443c82750dd9 240 }
lex9296 28:443c82750dd9 241
lex9296 28:443c82750dd9 242 if (out_PosizionatoreSW.i32_ATVSpeed != ms_0002_prec) {
lex9296 28:443c82750dd9 243 sprintf (StringText,
lex9296 28:443c82750dd9 244 "Speed[ui]: %d ", out_PosizionatoreSW.i32_ATVSpeed);
lex9296 28:443c82750dd9 245 LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31));
lex9296 28:443c82750dd9 246 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 3), StringText);
lex9296 28:443c82750dd9 247 ms_0002_prec = out_PosizionatoreSW.i32_ATVSpeed;
lex9296 28:443c82750dd9 248 }
lex9296 27:654100855f5c 249
lex9296 28:443c82750dd9 250 f_ai0000_Aux = adc_temp.read();
lex9296 28:443c82750dd9 251 if (f_ai0000_Aux != f_ai0000_prec) {
lex9296 28:443c82750dd9 252 sprintf (StringText,
lex9296 28:443c82750dd9 253 // "ADC Temp = %f\n", (f_ai0000_Aux* 100));
lex9296 28:443c82750dd9 254 "ADC Temp = %f ", (f_ai0000_Aux* 100));
lex9296 28:443c82750dd9 255 LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31));
lex9296 28:443c82750dd9 256 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 4), StringText);
lex9296 28:443c82750dd9 257 f_ai0000_prec = f_ai0000_Aux;
lex9296 28:443c82750dd9 258 }
lex9296 27:654100855f5c 259
lex9296 28:443c82750dd9 260 f_ai0000_Aux = adc_vbat.read();
lex9296 28:443c82750dd9 261 if (f_ai0000_Aux != f_ai0001_prec) {
lex9296 28:443c82750dd9 262 sprintf (StringText,
lex9296 28:443c82750dd9 263 // "ADC VBat = %f\n", (f_ai0000_Aux* 100));
lex9296 28:443c82750dd9 264 "ADC VBat = %f ", (f_ai0000_Aux));
lex9296 28:443c82750dd9 265 LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31));
lex9296 28:443c82750dd9 266 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 5), StringText);
lex9296 28:443c82750dd9 267 f_ai0001_prec = f_ai0000_Aux;
lex9296 28:443c82750dd9 268 }
lex9296 27:654100855f5c 269
lex9296 28:443c82750dd9 270 f_ai0000_Aux = adc_vref.read();
lex9296 28:443c82750dd9 271 if (f_ai0000_Aux != f_ai0002_prec) {
lex9296 28:443c82750dd9 272 sprintf (StringText,
lex9296 28:443c82750dd9 273 // "ADC VRef = %f\n", (f_ai0000_Aux* 100));
lex9296 28:443c82750dd9 274 "ADC VRef = %f ", (f_ai0000_Aux));
lex9296 28:443c82750dd9 275 LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31));
lex9296 28:443c82750dd9 276 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 6), StringText);
lex9296 28:443c82750dd9 277 f_ai0002_prec = f_ai0000_Aux;
lex9296 28:443c82750dd9 278 }
lex9296 29:7ce8c5779f5e 279
lex9296 29:7ce8c5779f5e 280 f_ai0000_Aux = ADC12_IN9.read();
lex9296 29:7ce8c5779f5e 281 if (f_ai0000_Aux != f_ai0003_prec) {
lex9296 29:7ce8c5779f5e 282 sprintf (StringText,
lex9296 29:7ce8c5779f5e 283 "ADC12.09 = %f ", (f_ai0000_Aux));
lex9296 29:7ce8c5779f5e 284 LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31));
lex9296 29:7ce8c5779f5e 285 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 8), StringText);
lex9296 29:7ce8c5779f5e 286 f_ai0003_prec = f_ai0000_Aux;
lex9296 29:7ce8c5779f5e 287 }
lex9296 29:7ce8c5779f5e 288
lex9296 29:7ce8c5779f5e 289 f_ai0000_Aux = ADC12_IN15.read();
lex9296 29:7ce8c5779f5e 290 if (f_ai0000_Aux != f_ai0004_prec) {
lex9296 29:7ce8c5779f5e 291 sprintf (StringText,
lex9296 29:7ce8c5779f5e 292 "ADC12.15 = %f ", (f_ai0000_Aux));
lex9296 29:7ce8c5779f5e 293 LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31));
lex9296 29:7ce8c5779f5e 294 LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 9), StringText);
lex9296 29:7ce8c5779f5e 295 f_ai0004_prec = f_ai0000_Aux;
lex9296 29:7ce8c5779f5e 296 }
lex9296 29:7ce8c5779f5e 297
lex9296 29:7ce8c5779f5e 298 // LA: Scope, Theory of operation.
lex9296 29:7ce8c5779f5e 299 // ===========================
lex9296 29:7ce8c5779f5e 300 //
lex9296 29:7ce8c5779f5e 301 // 1) Sample a Value @ any Step
lex9296 29:7ce8c5779f5e 302 // 2) Store @ the correct ms
lex9296 29:7ce8c5779f5e 303 // 3) Plot the current Section of the Sampling Vector
lex9296 29:7ce8c5779f5e 304 //
lex9296 29:7ce8c5779f5e 305
lex9296 28:443c82750dd9 306 }
lex9296 28:443c82750dd9 307 }
lex9296 28:443c82750dd9 308
lex9296 29:7ce8c5779f5e 309 static void SampleAndStore (void) {
lex9296 29:7ce8c5779f5e 310 int16_t i16_SampleIndex;
lex9296 29:7ce8c5779f5e 311 //float f_SampleAux;
lex9296 29:7ce8c5779f5e 312
lex9296 29:7ce8c5779f5e 313 af_PlotSamples[240- 1] = ADC12_IN9.read();
lex9296 29:7ce8c5779f5e 314 for (i16_SampleIndex = 0; i16_SampleIndex < (240- 1); i16_SampleIndex++) {
lex9296 29:7ce8c5779f5e 315 af_PlotSamples[i16_SampleIndex] = af_PlotSamples[i16_SampleIndex+ 1];
lex9296 29:7ce8c5779f5e 316 }
lex9296 29:7ce8c5779f5e 317
lex9296 29:7ce8c5779f5e 318 i32_Pulses++;
lex9296 29:7ce8c5779f5e 319 }
lex9296 29:7ce8c5779f5e 320
lex9296 29:7ce8c5779f5e 321 // Funziona, resta solo da plottare.
lex9296 29:7ce8c5779f5e 322 // Funziona, resta solo da plottare.
lex9296 29:7ce8c5779f5e 323 // Funziona, resta solo da plottare.
lex9296 29:7ce8c5779f5e 324 // Funziona, resta solo da plottare.
lex9296 29:7ce8c5779f5e 325
lex9296 28:443c82750dd9 326 /*
lex9296 27:654100855f5c 327 while (ui16_TestStep < 32) {
lex9296 27:654100855f5c 328
lex9296 27:654100855f5c 329 ui16_TestColor = Scale2RGBColor (ui16_R, ui16_G, ui16_B);
lex9296 27:654100855f5c 330 LCM_ClearScreen (ui16_TestColor);
lex9296 27:654100855f5c 331 LCM_SetTextColor(ui16_TestColor, (0xffff- ui16_TestColor));
lex9296 27:654100855f5c 332 sprintf (StringText,
lex9296 27:654100855f5c 333 "Color: %04x %04x ", ui16_TestColor, ui16_TestStep);
lex9296 27:654100855f5c 334 LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), StringText);
lex9296 27:654100855f5c 335 sprintf (StringText,
lex9296 27:654100855f5c 336 "R:%02x G:%02x B:%02x ", ui16_R, ui16_G, ui16_B);
lex9296 27:654100855f5c 337 LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 5), StringText);
lex9296 27:654100855f5c 338 // delay (500);
lex9296 27:654100855f5c 339
lex9296 27:654100855f5c 340 ui16_R++;
lex9296 27:654100855f5c 341 ui16_G++;
lex9296 27:654100855f5c 342 ui16_B++;
lex9296 27:654100855f5c 343 // ui16_TestColor += 0x0841;
lex9296 27:654100855f5c 344 ui16_TestStep ++;
lex9296 27:654100855f5c 345 }
lex9296 27:654100855f5c 346 delay (2500);
lex9296 28:443c82750dd9 347 */