Stabilus 322699 wDoublePID
Dependencies: mbed QEI PID DmTftLibraryEx
main.cpp@27:654100855f5c, 2022-02-15 (annotated)
- Committer:
- lex9296
- Date:
- Tue Feb 15 07:22:09 2022 +0000
- Revision:
- 27:654100855f5c
- Parent:
- 26:bfca0c471a87
- Child:
- 28:443c82750dd9
Release "Stabile"
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GregCr | 0:9c0917bfde97 | 1 | |
lex9296 | 23:b9d23a2f390e | 2 | //Warning: Incompatible redefinition of macro "MBED_RAM_SIZE" in "tmp/HU5Hqj", Line: 39, Col: 10 |
lex9296 | 23:b9d23a2f390e | 3 | #ifndef MBED_RAM_SIZE |
lex9296 | 23:b9d23a2f390e | 4 | #define MBED_RAM_SIZE 0x00018000 |
lex9296 | 23:b9d23a2f390e | 5 | #endif |
lex9296 | 23:b9d23a2f390e | 6 | |
lex9296 | 23:b9d23a2f390e | 7 | #include "QEI.h" |
lex9296 | 23:b9d23a2f390e | 8 | #include "SWPos.h" |
lex9296 | 23:b9d23a2f390e | 9 | |
GregCr | 0:9c0917bfde97 | 10 | #include "Timers.h" |
lex9296 | 23:b9d23a2f390e | 11 | //#include "Menu.h" |
GregCr | 0:9c0917bfde97 | 12 | #include "Eeprom.h" |
lex9296 | 23:b9d23a2f390e | 13 | //#include "main.h" |
lex9296 | 23:b9d23a2f390e | 14 | //#include "app_config.h" |
GregCr | 0:9c0917bfde97 | 15 | |
lex9296 | 27:654100855f5c | 16 | #define MAX_CHAR_PER_LINE 28 |
lex9296 | 27:654100855f5c | 17 | #define TEXT_ROW_SPACING 16 |
lex9296 | 27:654100855f5c | 18 | #define FONT_CHAR_WIDTH 8 |
lex9296 | 27:654100855f5c | 19 | #define FONT_CHAR_HEIGHT 16 |
lex9296 | 27:654100855f5c | 20 | |
lex9296 | 27:654100855f5c | 21 | //#include "mbed.h" |
lex9296 | 27:654100855f5c | 22 | #include "DisplayDriver.h" |
lex9296 | 27:654100855f5c | 23 | //#include "DmTftIli9341.h" |
lex9296 | 27:654100855f5c | 24 | //#include "DmTouch.h" |
lex9296 | 27:654100855f5c | 25 | //#include "DmTouchCalibration.h" |
lex9296 | 27:654100855f5c | 26 | |
lex9296 | 26:bfca0c471a87 | 27 | // LA: Theory of Operation |
lex9296 | 26:bfca0c471a87 | 28 | // =================== |
lex9296 | 26:bfca0c471a87 | 29 | // |
lex9296 | 26:bfca0c471a87 | 30 | // Il PWM funziona da sè in Interrupt |
lex9296 | 26:bfca0c471a87 | 31 | // Il QEI funziona da sè in Interrupt |
lex9296 | 26:bfca0c471a87 | 32 | // 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 | 33 | // |
lex9296 | 26:bfca0c471a87 | 34 | // PQM |
lex9296 | 26:bfca0c471a87 | 35 | // |
lex9296 | 26:bfca0c471a87 | 36 | // Il rinfresco del Display e la gestione del motion vanno fatte il più frequentemente possibile ma fuori dal loop dei Ticker. |
lex9296 | 26:bfca0c471a87 | 37 | // Con qst versione (LA0005, che termina un FORK (il successivo è LA0010) quanto detto sopra è FUNZIONANTE. |
lex9296 | 26:bfca0c471a87 | 38 | // Questo messaggio è incluso nel "commitment" |
lex9296 | 26:bfca0c471a87 | 39 | |
GregCr | 0:9c0917bfde97 | 40 | /*! |
GregCr | 0:9c0917bfde97 | 41 | * \brief Define IO for Unused Pin |
GregCr | 0:9c0917bfde97 | 42 | */ |
lex9296 | 23:b9d23a2f390e | 43 | //DigitalOut F_CS (D6); // MBED description of pin |
lex9296 | 23:b9d23a2f390e | 44 | //DigitalOut SD_CS (D8); // MBED description of pin |
lex9296 | 23:b9d23a2f390e | 45 | |
lex9296 | 23:b9d23a2f390e | 46 | DigitalIn userButton (USER_BUTTON); |
mverdy | 15:ed7ed20b7114 | 47 | |
lex9296 | 23:b9d23a2f390e | 48 | AnalogIn adc_temp (ADC_TEMP); |
lex9296 | 23:b9d23a2f390e | 49 | AnalogIn adc_vref (ADC_VREF); |
lex9296 | 23:b9d23a2f390e | 50 | AnalogIn adc_vbat (ADC_VBAT); |
GregCr | 0:9c0917bfde97 | 51 | |
lex9296 | 23:b9d23a2f390e | 52 | // PWM |
lex9296 | 23:b9d23a2f390e | 53 | // === |
lex9296 | 23:b9d23a2f390e | 54 | // |
lex9296 | 25:5fd2d69e2927 | 55 | PwmOut PWM_PB3(PWM_OUT); // LA: PWM_OUT = D3 = PB_3 |
mverdy | 14:ebd89dacc807 | 56 | |
lex9296 | 23:b9d23a2f390e | 57 | // Motion |
lex9296 | 23:b9d23a2f390e | 58 | // ====== |
lex9296 | 23:b9d23a2f390e | 59 | // |
lex9296 | 23:b9d23a2f390e | 60 | //Ticker POS_MotionScan; // |
mverdy | 15:ed7ed20b7114 | 61 | |
lex9296 | 23:b9d23a2f390e | 62 | QEI Stabilus322699 (PA_1, PA_0, NC, 100, QEI::X4_ENCODING); |
lex9296 | 23:b9d23a2f390e | 63 | // |
lex9296 | 23:b9d23a2f390e | 64 | in_sPosizionatoreSW in_PosizionatoreSW; |
lex9296 | 23:b9d23a2f390e | 65 | out_sPosizionatoreSW out_PosizionatoreSW; |
GregCr | 0:9c0917bfde97 | 66 | |
lex9296 | 23:b9d23a2f390e | 67 | // LCD Display |
lex9296 | 23:b9d23a2f390e | 68 | // =========== |
lex9296 | 23:b9d23a2f390e | 69 | // |
lex9296 | 23:b9d23a2f390e | 70 | //Ticker LCD_RefreshViews; // |
lex9296 | 23:b9d23a2f390e | 71 | |
lex9296 | 23:b9d23a2f390e | 72 | //extern void StabilusMenu (uint32_t, uint32_t, int64_t); // LA: Prototype ... |
mverdy | 15:ed7ed20b7114 | 73 | |
lex9296 | 22:12c555cade79 | 74 | void FactoryReset (void) { |
mverdy | 15:ed7ed20b7114 | 75 | EepromFactoryReset( ); |
mverdy | 15:ed7ed20b7114 | 76 | HAL_NVIC_SystemReset( ); |
mverdy | 15:ed7ed20b7114 | 77 | } |
lex9296 | 23:b9d23a2f390e | 78 | |
lex9296 | 23:b9d23a2f390e | 79 | /* |
lex9296 | 23:b9d23a2f390e | 80 | void LCD____tScan (void) { |
lex9296 | 23:b9d23a2f390e | 81 | // StabilusMenu (out_PosizionatoreSW.ui32_PreviousStep_ms, out_PosizionatoreSW.ui32_ActualStepSampled_ms, out_PosizionatoreSW.ui32_PassedActual_ms); |
lex9296 | 23:b9d23a2f390e | 82 | } |
lex9296 | 23:b9d23a2f390e | 83 | |
lex9296 | 23:b9d23a2f390e | 84 | |
lex9296 | 23:b9d23a2f390e | 85 | void Motion_tScan (void) { |
lex9296 | 23:b9d23a2f390e | 86 | PosizionatoreSW (in_PosizionatoreSW, out_PosizionatoreSW); |
lex9296 | 23:b9d23a2f390e | 87 | } |
lex9296 | 23:b9d23a2f390e | 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 | 23:b9d23a2f390e | 97 | //int32_t i32_Pulses; |
lex9296 | 23:b9d23a2f390e | 98 | // F_CS = 1; // LA: HW Initialization InProgress |
lex9296 | 23:b9d23a2f390e | 99 | // SD_CS = 1; // LA: HW Initialization InProgress |
lex9296 | 23:b9d23a2f390e | 100 | // BoardLED3 = 1; |
lex9296 | 23:b9d23a2f390e | 101 | |
lex9296 | 23:b9d23a2f390e | 102 | EepromInit(); // LA: Inizializza la EEProm |
lex9296 | 23:b9d23a2f390e | 103 | TimersInit(); // LA: Parte il Timer a 1ms |
lex9296 | 23:b9d23a2f390e | 104 | |
lex9296 | 23:b9d23a2f390e | 105 | // LA: FactoryReset se "userButton" premuto all'avvio |
lex9296 | 23:b9d23a2f390e | 106 | // |
lex9296 | 23:b9d23a2f390e | 107 | if (userButton == 0) { |
lex9296 | 23:b9d23a2f390e | 108 | FactoryReset(); |
lex9296 | 23:b9d23a2f390e | 109 | } |
lex9296 | 23:b9d23a2f390e | 110 | |
lex9296 | 27:654100855f5c | 111 | DisplayDriverInit(); |
lex9296 | 27:654100855f5c | 112 | // LCM_SetTextColor(BLUE, BLACK); |
lex9296 | 27:654100855f5c | 113 | // LCM_SetTextColor(GRAY1, BLACK); |
lex9296 | 27:654100855f5c | 114 | // LCM_SetTextColor(GRAY2, WHITE); |
lex9296 | 27:654100855f5c | 115 | LCM_SetTextColor(BLACK, WHITE); |
lex9296 | 27:654100855f5c | 116 | |
lex9296 | 27:654100855f5c | 117 | // MenuInit(); // LA: Inizializza il Display |
lex9296 | 23:b9d23a2f390e | 118 | // LCD_RefreshViews.attach_us (&LCD____tScan, 250000); // Scansione LCD @100ms |
lex9296 | 23:b9d23a2f390e | 119 | |
lex9296 | 23:b9d23a2f390e | 120 | // LA: Motion (1st) Setup |
lex9296 | 23:b9d23a2f390e | 121 | // |
lex9296 | 23:b9d23a2f390e | 122 | in_PosizionatoreSW.b_AxisPowered = false; |
lex9296 | 23:b9d23a2f390e | 123 | in_PosizionatoreSW.b_ACPos_Homed = false; |
lex9296 | 23:b9d23a2f390e | 124 | in_PosizionatoreSW.i32_Max_Speed = 1024; // [ui] |
lex9296 | 23:b9d23a2f390e | 125 | in_PosizionatoreSW.i32_ZeroSpeed = 0; // |
lex9296 | 23:b9d23a2f390e | 126 | |
lex9296 | 23:b9d23a2f390e | 127 | in_PosizionatoreSW.b_JogMode = false; |
lex9296 | 23:b9d23a2f390e | 128 | in_PosizionatoreSW.b_JogFW = false; |
lex9296 | 23:b9d23a2f390e | 129 | in_PosizionatoreSW.b_JogBW = false; |
lex9296 | 23:b9d23a2f390e | 130 | in_PosizionatoreSW.i32_JogAccel_ms = 500; // [ms] |
lex9296 | 23:b9d23a2f390e | 131 | in_PosizionatoreSW.i32_JogDecel_ms = 250; // |
lex9296 | 23:b9d23a2f390e | 132 | // |
lex9296 | 23:b9d23a2f390e | 133 | in_PosizionatoreSW.f_JogSpeed_x100_FW = 25.0; // % of "i32_Max_Speed" |
lex9296 | 23:b9d23a2f390e | 134 | in_PosizionatoreSW.f_JogSpeed_x100_BW = 25.0; // |
lex9296 | 23:b9d23a2f390e | 135 | |
lex9296 | 23:b9d23a2f390e | 136 | in_PosizionatoreSW.b_ServoLock = false; |
lex9296 | 23:b9d23a2f390e | 137 | in_PosizionatoreSW.rtServoLock_Q = false; |
lex9296 | 23:b9d23a2f390e | 138 | // |
lex9296 | 23:b9d23a2f390e | 139 | in_PosizionatoreSW.i64_TargetPosition = 0; // [ui] |
lex9296 | 23:b9d23a2f390e | 140 | in_PosizionatoreSW.i64_ActualPosition = 0; // |
lex9296 | 23:b9d23a2f390e | 141 | in_PosizionatoreSW.i64_AccelerationWindow = 0; // LA: Spazio concesso all'accelerazione. |
lex9296 | 23:b9d23a2f390e | 142 | in_PosizionatoreSW.i64_DecelerationWindow = 0; // Spazio concesso alla decelerazione, è prioritario rispetto all'accelerazione. |
lex9296 | 23:b9d23a2f390e | 143 | in_PosizionatoreSW.i64_diToleranceWindow = 0; // Finestra di Tolleranza |
lex9296 | 23:b9d23a2f390e | 144 | // |
lex9296 | 23:b9d23a2f390e | 145 | in_PosizionatoreSW.f_MaximumSpeed_x100_FW = 25.0; // % of "i32_Max_Speed" |
lex9296 | 23:b9d23a2f390e | 146 | in_PosizionatoreSW.f_MaximumSpeed_x100_BW = 25.0; // |
lex9296 | 23:b9d23a2f390e | 147 | in_PosizionatoreSW.f_ServoLockSpeed_x100_FW = 5.0; // |
lex9296 | 23:b9d23a2f390e | 148 | in_PosizionatoreSW.f_ServoLockSpeed_x100_BW = 5.0; // |
lex9296 | 23:b9d23a2f390e | 149 | |
lex9296 | 23:b9d23a2f390e | 150 | // POS_MotionScan.attach_us (&Motion_tScan, 2000); // LA: Scansione Motion @2ms |
lex9296 | 23:b9d23a2f390e | 151 | |
lex9296 | 23:b9d23a2f390e | 152 | // PWM_SetOut.attach_us (&PWM____tScan, 100); // Scansione base PWM @100us Ok |
lex9296 | 23:b9d23a2f390e | 153 | // PWM_SetOut.attach_us (&PWM____tScan, 50); // Scansione base PWM @50us Ok |
lex9296 | 23:b9d23a2f390e | 154 | // PWM_SetOut.attach_us (&PWM____tScan, 30); // Scansione base PWM @30us Ok |
lex9296 | 23:b9d23a2f390e | 155 | // PWM_SetOut.attach_us (&PWM____tScan, 25); // Scansione base PWM @25us No (al pelo ...) |
lex9296 | 23:b9d23a2f390e | 156 | // PWM_SetOut.attach_us (&PWM____tScan, 10); // Scansione base PWM @10us No (al pelo ...) |
lex9296 | 23:b9d23a2f390e | 157 | // PWM_SetOut.attach_us (&PWM____tScan, 20); // Scansione base PWM @20us No |
lex9296 | 23:b9d23a2f390e | 158 | |
lex9296 | 23:b9d23a2f390e | 159 | // PWM_SetOut.attach_us (&PWM____tScan, 40); // Scansione base PWM @40us, Duty Cycle 4ms, 0- 100% |
lex9296 | 23:b9d23a2f390e | 160 | // PWM_SetOut.attach_us (&PWM____tScan, 100); // Scansione base PWM @40us, Duty Cycle 5ms, 0- 100% |
lex9296 | 23:b9d23a2f390e | 161 | |
lex9296 | 25:5fd2d69e2927 | 162 | PWM_PB3.period_us(100); // LA: TimeBase is 100us |
lex9296 | 23:b9d23a2f390e | 163 | |
lex9296 | 27:654100855f5c | 164 | #define RED 0xf800 // 1111 1000 0000 0000 |
lex9296 | 27:654100855f5c | 165 | #define GREEN 0x07e0 // 0000 0111 1110 0000 |
lex9296 | 27:654100855f5c | 166 | #define BLUE 0x001f // 0000 0000 0001 1111 |
lex9296 | 27:654100855f5c | 167 | #define BLACK 0x0000 // 0000 0000 0000 0000 |
lex9296 | 27:654100855f5c | 168 | #define YELLOW 0xffe0 // 1111 1111 1110 0000 |
lex9296 | 27:654100855f5c | 169 | #define WHITE 0xffff // 1111 1111 1111 1111 |
lex9296 | 27:654100855f5c | 170 | |
lex9296 | 27:654100855f5c | 171 | #define CYAN 0x07ff // 0000 0111 1111 1111 |
lex9296 | 27:654100855f5c | 172 | #define BRIGHT_RED 0xf810 // 1111 1000 0001 0000 |
lex9296 | 27:654100855f5c | 173 | #define GRAY1 0x8410 // 1000 0100 0001 0000 |
lex9296 | 27:654100855f5c | 174 | #define GRAY2 0x4208 // 0100 0010 0000 1000 |
lex9296 | 27:654100855f5c | 175 | |
lex9296 | 27:654100855f5c | 176 | // LA: Color RGB Component(s) |
lex9296 | 27:654100855f5c | 177 | // ====================== |
lex9296 | 27:654100855f5c | 178 | // |
lex9296 | 27:654100855f5c | 179 | // RED 0000 1000 0000 0000 min 0x0800 02048 |
lex9296 | 27:654100855f5c | 180 | // 1111 1000 0000 0000 max 0xf800 63488 |
lex9296 | 27:654100855f5c | 181 | // |
lex9296 | 27:654100855f5c | 182 | // GREEN 0000 0000 0010 0000 min 0x0020 00032 |
lex9296 | 27:654100855f5c | 183 | // 0000 0111 1110 0000 max 0x07e0 02016 |
lex9296 | 27:654100855f5c | 184 | // |
lex9296 | 27:654100855f5c | 185 | // BLUE 0000 0000 0000 0001 min 0x0001 00001 |
lex9296 | 27:654100855f5c | 186 | // 0000 0000 0001 1111 max 0x001f 00031 |
lex9296 | 27:654100855f5c | 187 | // |
lex9296 | 27:654100855f5c | 188 | // La componente ROSSA ha 5 bit di escursione (0.. 31), |
lex9296 | 27:654100855f5c | 189 | // La componente VERDE ha 6 bit di escursione (0.. 63), |
lex9296 | 27:654100855f5c | 190 | // La componente BLU ha 5 bit di escursione (0.. 31), |
lex9296 | 27:654100855f5c | 191 | // |
lex9296 | 27:654100855f5c | 192 | // Le componenti RGB di "Color" sono quindi scritte negli appropriati registri come segue: |
lex9296 | 27:654100855f5c | 193 | // |
lex9296 | 27:654100855f5c | 194 | // writeReg(RED, (Color & 0xf800) >> 11); |
lex9296 | 27:654100855f5c | 195 | // writeReg(GREEN, (Color & 0x07e0) >> 5); |
lex9296 | 27:654100855f5c | 196 | // writeReg(BLUE, (Color & 0x001f)); |
lex9296 | 27:654100855f5c | 197 | // |
lex9296 | 27:654100855f5c | 198 | |
lex9296 | 27:654100855f5c | 199 | // LCM_ClearScreen (GRAY1); |
lex9296 | 27:654100855f5c | 200 | // LCM_ClearScreen (BLACK); |
lex9296 | 27:654100855f5c | 201 | // LCM_ClearScreen (GRAY2); |
lex9296 | 27:654100855f5c | 202 | |
lex9296 | 27:654100855f5c | 203 | char StringText[MAX_CHAR_PER_LINE + 1]; // don't forget the /0 (end of string) |
lex9296 | 27:654100855f5c | 204 | // char StringText2[MAX_CHAR_PER_LINE + 1]; |
lex9296 | 27:654100855f5c | 205 | // char StringText3[MAX_CHAR_PER_LINE + 1]; |
lex9296 | 27:654100855f5c | 206 | |
lex9296 | 27:654100855f5c | 207 | uint16_t ui16_TestColor = 0x0000; |
lex9296 | 27:654100855f5c | 208 | uint16_t ui16_TestStep = 0x0000; |
lex9296 | 27:654100855f5c | 209 | // |
lex9296 | 27:654100855f5c | 210 | uint16_t ui16_R = 0x00; |
lex9296 | 27:654100855f5c | 211 | uint16_t ui16_G = 0x00; |
lex9296 | 27:654100855f5c | 212 | uint16_t ui16_B = 0x00; |
lex9296 | 27:654100855f5c | 213 | |
lex9296 | 27:654100855f5c | 214 | while (ui16_TestStep < 32) { |
lex9296 | 27:654100855f5c | 215 | |
lex9296 | 27:654100855f5c | 216 | ui16_TestColor = Scale2RGBColor (ui16_R, ui16_G, ui16_B); |
lex9296 | 27:654100855f5c | 217 | LCM_ClearScreen (ui16_TestColor); |
lex9296 | 27:654100855f5c | 218 | LCM_SetTextColor(ui16_TestColor, (0xffff- ui16_TestColor)); |
lex9296 | 27:654100855f5c | 219 | sprintf (StringText, |
lex9296 | 27:654100855f5c | 220 | "Color: %04x %04x ", ui16_TestColor, ui16_TestStep); |
lex9296 | 27:654100855f5c | 221 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), StringText); |
lex9296 | 27:654100855f5c | 222 | sprintf (StringText, |
lex9296 | 27:654100855f5c | 223 | "R:%02x G:%02x B:%02x ", ui16_R, ui16_G, ui16_B); |
lex9296 | 27:654100855f5c | 224 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 5), StringText); |
lex9296 | 27:654100855f5c | 225 | // delay (500); |
lex9296 | 27:654100855f5c | 226 | |
lex9296 | 27:654100855f5c | 227 | ui16_R++; |
lex9296 | 27:654100855f5c | 228 | ui16_G++; |
lex9296 | 27:654100855f5c | 229 | ui16_B++; |
lex9296 | 27:654100855f5c | 230 | // ui16_TestColor += 0x0841; |
lex9296 | 27:654100855f5c | 231 | ui16_TestStep ++; |
lex9296 | 27:654100855f5c | 232 | } |
lex9296 | 27:654100855f5c | 233 | delay (2500); |
lex9296 | 27:654100855f5c | 234 | |
lex9296 | 27:654100855f5c | 235 | /* |
lex9296 | 27:654100855f5c | 236 | ui16_TestColor = 0x0000; |
lex9296 | 27:654100855f5c | 237 | ui16_TestStep = 0x0000; |
lex9296 | 27:654100855f5c | 238 | while (ui16_TestStep < 32) { |
lex9296 | 27:654100855f5c | 239 | |
lex9296 | 27:654100855f5c | 240 | LCM_ClearScreen (ui16_TestColor); |
lex9296 | 27:654100855f5c | 241 | LCM_SetTextColor(ui16_TestColor, (0xffff- ui16_TestColor)); |
lex9296 | 27:654100855f5c | 242 | sprintf (StringText, |
lex9296 | 27:654100855f5c | 243 | "Color: %#04x %#04x ", ui16_TestColor, ui16_TestStep); |
lex9296 | 27:654100855f5c | 244 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), StringText); |
lex9296 | 27:654100855f5c | 245 | |
lex9296 | 27:654100855f5c | 246 | // ui16_TestColor += 0x0841; |
lex9296 | 27:654100855f5c | 247 | ui16_TestColor += 0x0001; |
lex9296 | 27:654100855f5c | 248 | ui16_TestStep ++; |
lex9296 | 27:654100855f5c | 249 | } |
lex9296 | 27:654100855f5c | 250 | |
lex9296 | 27:654100855f5c | 251 | ui16_TestColor = 0x0000; |
lex9296 | 27:654100855f5c | 252 | ui16_TestStep = 0x0000; |
lex9296 | 27:654100855f5c | 253 | while (ui16_TestStep < 32) { |
lex9296 | 27:654100855f5c | 254 | |
lex9296 | 27:654100855f5c | 255 | LCM_ClearScreen (ui16_TestColor); |
lex9296 | 27:654100855f5c | 256 | LCM_SetTextColor(ui16_TestColor, (0xffff- ui16_TestColor)); |
lex9296 | 27:654100855f5c | 257 | sprintf (StringText, |
lex9296 | 27:654100855f5c | 258 | "Color: %#04x %#04x ", ui16_TestColor, ui16_TestStep); |
lex9296 | 27:654100855f5c | 259 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), StringText); |
lex9296 | 27:654100855f5c | 260 | |
lex9296 | 27:654100855f5c | 261 | // ui16_TestColor += 0x0841; |
lex9296 | 27:654100855f5c | 262 | ui16_TestColor += 0x0040; |
lex9296 | 27:654100855f5c | 263 | ui16_TestStep ++; |
lex9296 | 27:654100855f5c | 264 | } |
lex9296 | 27:654100855f5c | 265 | |
lex9296 | 27:654100855f5c | 266 | ui16_TestColor = 0x0000; |
lex9296 | 27:654100855f5c | 267 | ui16_TestStep = 0x0000; |
lex9296 | 27:654100855f5c | 268 | while (ui16_TestStep < 32) { |
lex9296 | 27:654100855f5c | 269 | |
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 | |
lex9296 | 27:654100855f5c | 276 | // ui16_TestColor += 0x0841; |
lex9296 | 27:654100855f5c | 277 | ui16_TestColor += 0x0800; |
lex9296 | 27:654100855f5c | 278 | ui16_TestStep ++; |
lex9296 | 27:654100855f5c | 279 | } |
lex9296 | 27:654100855f5c | 280 | |
lex9296 | 27:654100855f5c | 281 | ui16_TestColor = 0x0000; |
lex9296 | 27:654100855f5c | 282 | ui16_TestStep = 0x0000; |
lex9296 | 27:654100855f5c | 283 | while (ui16_TestStep < 32) { |
lex9296 | 27:654100855f5c | 284 | |
lex9296 | 27:654100855f5c | 285 | LCM_ClearScreen (ui16_TestColor); |
lex9296 | 27:654100855f5c | 286 | LCM_SetTextColor(ui16_TestColor, (0xffff- ui16_TestColor)); |
lex9296 | 27:654100855f5c | 287 | sprintf (StringText, |
lex9296 | 27:654100855f5c | 288 | "Color: %#04x %#04x ", ui16_TestColor, ui16_TestStep); |
lex9296 | 27:654100855f5c | 289 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), StringText); |
lex9296 | 27:654100855f5c | 290 | |
lex9296 | 27:654100855f5c | 291 | // ui16_TestColor += 0x0841; |
lex9296 | 27:654100855f5c | 292 | ui16_TestColor += 0x0041; |
lex9296 | 27:654100855f5c | 293 | ui16_TestStep ++; |
lex9296 | 27:654100855f5c | 294 | } |
lex9296 | 27:654100855f5c | 295 | |
lex9296 | 27:654100855f5c | 296 | ui16_TestColor = 0x0000; |
lex9296 | 27:654100855f5c | 297 | ui16_TestStep = 0x0000; |
lex9296 | 27:654100855f5c | 298 | while (ui16_TestStep < 32) { |
lex9296 | 27:654100855f5c | 299 | |
lex9296 | 27:654100855f5c | 300 | LCM_ClearScreen (ui16_TestColor); |
lex9296 | 27:654100855f5c | 301 | LCM_SetTextColor(ui16_TestColor, (0xffff- ui16_TestColor)); |
lex9296 | 27:654100855f5c | 302 | sprintf (StringText, |
lex9296 | 27:654100855f5c | 303 | "Color: %#04x %#04x ", ui16_TestColor, ui16_TestStep); |
lex9296 | 27:654100855f5c | 304 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), StringText); |
lex9296 | 27:654100855f5c | 305 | |
lex9296 | 27:654100855f5c | 306 | // ui16_TestColor += 0x0841; |
lex9296 | 27:654100855f5c | 307 | ui16_TestColor += 0x0840; |
lex9296 | 27:654100855f5c | 308 | ui16_TestStep ++; |
lex9296 | 27:654100855f5c | 309 | } |
lex9296 | 27:654100855f5c | 310 | |
lex9296 | 27:654100855f5c | 311 | ui16_TestColor = 0x0000; |
lex9296 | 27:654100855f5c | 312 | ui16_TestStep = 0x0000; |
lex9296 | 27:654100855f5c | 313 | while (ui16_TestStep < 32) { |
lex9296 | 27:654100855f5c | 314 | |
lex9296 | 27:654100855f5c | 315 | LCM_ClearScreen (ui16_TestColor); |
lex9296 | 27:654100855f5c | 316 | LCM_SetTextColor(ui16_TestColor, (0xffff- ui16_TestColor)); |
lex9296 | 27:654100855f5c | 317 | sprintf (StringText, |
lex9296 | 27:654100855f5c | 318 | "Color: %#04x %#04x ", ui16_TestColor, ui16_TestStep); |
lex9296 | 27:654100855f5c | 319 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), StringText); |
lex9296 | 27:654100855f5c | 320 | |
lex9296 | 27:654100855f5c | 321 | // ui16_TestColor += 0x0841; |
lex9296 | 27:654100855f5c | 322 | ui16_TestColor += 0x0801; |
lex9296 | 27:654100855f5c | 323 | ui16_TestStep ++; |
lex9296 | 27:654100855f5c | 324 | } |
lex9296 | 27:654100855f5c | 325 | |
lex9296 | 27:654100855f5c | 326 | delay (5000); |
lex9296 | 27:654100855f5c | 327 | */ |
lex9296 | 27:654100855f5c | 328 | /* |
lex9296 | 27:654100855f5c | 329 | LCM_ClearScreen (0x07e0); |
lex9296 | 27:654100855f5c | 330 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), "0x07e0"); |
lex9296 | 27:654100855f5c | 331 | delay (1000); |
lex9296 | 27:654100855f5c | 332 | LCM_ClearScreen (0x07c0); |
lex9296 | 27:654100855f5c | 333 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), "0x07c0"); |
lex9296 | 27:654100855f5c | 334 | delay (1000); |
lex9296 | 27:654100855f5c | 335 | LCM_ClearScreen (0x07e0); |
lex9296 | 27:654100855f5c | 336 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), "0x07e0"); |
lex9296 | 27:654100855f5c | 337 | delay (1000); |
lex9296 | 27:654100855f5c | 338 | LCM_ClearScreen (0x07c0); |
lex9296 | 27:654100855f5c | 339 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), "0x07c0"); |
lex9296 | 27:654100855f5c | 340 | delay (1000); |
lex9296 | 27:654100855f5c | 341 | |
lex9296 | 27:654100855f5c | 342 | LCM_ClearScreen (0x0000); |
lex9296 | 27:654100855f5c | 343 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), "0x0000"); |
lex9296 | 27:654100855f5c | 344 | delay (1000); |
lex9296 | 27:654100855f5c | 345 | LCM_ClearScreen (0x0020); |
lex9296 | 27:654100855f5c | 346 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), "0x0020"); |
lex9296 | 27:654100855f5c | 347 | delay (1000); |
lex9296 | 27:654100855f5c | 348 | LCM_ClearScreen (0x0040); |
lex9296 | 27:654100855f5c | 349 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), "0x0040"); |
lex9296 | 27:654100855f5c | 350 | delay (1000); |
lex9296 | 27:654100855f5c | 351 | LCM_ClearScreen (0x0020); |
lex9296 | 27:654100855f5c | 352 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), "0x0020"); |
lex9296 | 27:654100855f5c | 353 | delay (1000); |
lex9296 | 27:654100855f5c | 354 | LCM_ClearScreen (0x0040); |
lex9296 | 27:654100855f5c | 355 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), "0x0040"); |
lex9296 | 27:654100855f5c | 356 | delay (1000); |
lex9296 | 27:654100855f5c | 357 | LCM_ClearScreen (0x0000); |
lex9296 | 27:654100855f5c | 358 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 4), "0x0000"); |
lex9296 | 27:654100855f5c | 359 | delay (1000); |
lex9296 | 27:654100855f5c | 360 | |
lex9296 | 27:654100855f5c | 361 | */ |
lex9296 | 27:654100855f5c | 362 | ui16_TestColor = Scale2RGBColor (ui16_R, ui16_G, ui16_B); |
lex9296 | 27:654100855f5c | 363 | LCM_SetTextColor ( |
lex9296 | 27:654100855f5c | 364 | Scale2RGBColor (0, 0, 0), |
lex9296 | 27:654100855f5c | 365 | Scale2RGBColor (31, 31, 31) |
lex9296 | 27:654100855f5c | 366 | ); |
lex9296 | 27:654100855f5c | 367 | LCM_DrawString (0, 0+(TEXT_ROW_SPACING* 0), "You Start Me Up ..."); |
lex9296 | 27:654100855f5c | 368 | |
lex9296 | 23:b9d23a2f390e | 369 | while (1) { |
lex9296 | 27:654100855f5c | 370 | static int32_t Pulses_Prec; |
lex9296 | 27:654100855f5c | 371 | static uint32_t ms_0003_prec; |
lex9296 | 27:654100855f5c | 372 | int32_t i32_Pulses; |
lex9296 | 27:654100855f5c | 373 | |
lex9296 | 26:bfca0c471a87 | 374 | i32_Pulses = Stabilus322699.getPulses(); |
lex9296 | 23:b9d23a2f390e | 375 | |
lex9296 | 25:5fd2d69e2927 | 376 | PosizionatoreSW (in_PosizionatoreSW, out_PosizionatoreSW); |
lex9296 | 26:bfca0c471a87 | 377 | PWM_PB3.pulsewidth_us(((float)i32_Pulses/ (float)5000.0)* (float)100.0); // 0.. 100us -> 0.. 100% |
lex9296 | 25:5fd2d69e2927 | 378 | |
lex9296 | 23:b9d23a2f390e | 379 | // LA: Wedge 4 LCDRefresh |
lex9296 | 27:654100855f5c | 380 | if ( |
lex9296 | 27:654100855f5c | 381 | (i32_Pulses != Pulses_Prec) |
lex9296 | 27:654100855f5c | 382 | ) { |
lex9296 | 27:654100855f5c | 383 | sprintf (StringText, |
lex9296 | 27:654100855f5c | 384 | "Pulses: %d ", i32_Pulses); |
lex9296 | 27:654100855f5c | 385 | LCM_SetTextColor (Scale2RGBColor (0, 0, 31), Scale2RGBColor (31, 31, 0)); |
lex9296 | 27:654100855f5c | 386 | LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 1), StringText); |
lex9296 | 27:654100855f5c | 387 | } |
lex9296 | 27:654100855f5c | 388 | |
lex9296 | 27:654100855f5c | 389 | if (out_PosizionatoreSW.ui32_PassedActual_ms != ms_0003_prec) { |
lex9296 | 27:654100855f5c | 390 | sprintf (StringText, |
lex9296 | 27:654100855f5c | 391 | "PassedActual_ms: %d ", out_PosizionatoreSW.ui32_PassedActual_ms); |
lex9296 | 27:654100855f5c | 392 | LCM_SetTextColor (Scale2RGBColor (0, 31, 0), Scale2RGBColor (31, 0, 31)); |
lex9296 | 27:654100855f5c | 393 | LCM_DrawString (0, 0+ (TEXT_ROW_SPACING* 2), StringText); |
lex9296 | 27:654100855f5c | 394 | ms_0003_prec = out_PosizionatoreSW.ui32_PassedActual_ms; |
lex9296 | 27:654100855f5c | 395 | } |
lex9296 | 27:654100855f5c | 396 | // StabilusMenu (0, 0, out_PosizionatoreSW.ui32_PassedActual_ms, i32_Pulses); |
lex9296 | 23:b9d23a2f390e | 397 | } |
lex9296 | 23:b9d23a2f390e | 398 | } |