a
Dependencies: LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI
gui.cpp@6:06ff453bb16e, 2020-05-22 (annotated)
- Committer:
- matis755
- Date:
- Fri May 22 07:30:59 2020 +0000
- Revision:
- 6:06ff453bb16e
- Parent:
- 5:3c19c3ae6286
Use standard C functions
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
matis755 | 5:3c19c3ae6286 | 1 | #include "gui.h" |
matis755 | 5:3c19c3ae6286 | 2 | |
matis755 | 5:3c19c3ae6286 | 3 | #define pi 3.14159265359 |
matis755 | 5:3c19c3ae6286 | 4 | |
matis755 | 5:3c19c3ae6286 | 5 | Gui::Gui() { |
matis755 | 5:3c19c3ae6286 | 6 | Clear(LCD_COLOR_WHITE); |
matis755 | 5:3c19c3ae6286 | 7 | SetTextColor(LCD_COLOR_BLACK); |
matis755 | 5:3c19c3ae6286 | 8 | for(unsigned char i=0; i<4; i++) { |
matis755 | 5:3c19c3ae6286 | 9 | DrawCircle((32 + i*58), 284, 25); |
matis755 | 5:3c19c3ae6286 | 10 | } |
matis755 | 5:3c19c3ae6286 | 11 | DrawTop(); |
matis755 | 5:3c19c3ae6286 | 12 | DrawLine(120, 130, 120, 25); |
matis755 | 5:3c19c3ae6286 | 13 | ucInitialPos = 0; |
matis755 | 5:3c19c3ae6286 | 14 | } |
matis755 | 5:3c19c3ae6286 | 15 | |
matis755 | 5:3c19c3ae6286 | 16 | void Gui::DrawTop(void) { |
matis755 | 5:3c19c3ae6286 | 17 | SetTextColor(LCD_COLOR_BLACK); |
matis755 | 5:3c19c3ae6286 | 18 | DrawCircle(120, 130, 105); |
matis755 | 5:3c19c3ae6286 | 19 | FillCircle(120, 130, 105); |
matis755 | 5:3c19c3ae6286 | 20 | SetTextColor(LCD_COLOR_WHITE); |
matis755 | 5:3c19c3ae6286 | 21 | FillCircle(120, 130, 25); |
matis755 | 5:3c19c3ae6286 | 22 | } |
matis755 | 5:3c19c3ae6286 | 23 | |
matis755 | 5:3c19c3ae6286 | 24 | void Gui::RefreshLeds(unsigned char ucIdx) { |
matis755 | 5:3c19c3ae6286 | 25 | SetTextColor(LCD_COLOR_WHITE); |
matis755 | 5:3c19c3ae6286 | 26 | for(unsigned char i=0; i<4; i++) { |
matis755 | 5:3c19c3ae6286 | 27 | FillCircle((32 + i*58), 284, 24); |
matis755 | 5:3c19c3ae6286 | 28 | } |
matis755 | 5:3c19c3ae6286 | 29 | SetTextColor(LCD_COLOR_CYAN); |
matis755 | 5:3c19c3ae6286 | 30 | switch(ucIdx){ |
matis755 | 5:3c19c3ae6286 | 31 | case 0: |
matis755 | 5:3c19c3ae6286 | 32 | FillCircle(32, 284, 24); |
matis755 | 5:3c19c3ae6286 | 33 | break; |
matis755 | 5:3c19c3ae6286 | 34 | case 1: |
matis755 | 5:3c19c3ae6286 | 35 | FillCircle(90, 284, 24); |
matis755 | 5:3c19c3ae6286 | 36 | break; |
matis755 | 5:3c19c3ae6286 | 37 | case 2: |
matis755 | 5:3c19c3ae6286 | 38 | FillCircle(148, 284, 24); |
matis755 | 5:3c19c3ae6286 | 39 | break; |
matis755 | 5:3c19c3ae6286 | 40 | case 3: |
matis755 | 5:3c19c3ae6286 | 41 | FillCircle(206, 284, 24); |
matis755 | 5:3c19c3ae6286 | 42 | break; |
matis755 | 5:3c19c3ae6286 | 43 | default: |
matis755 | 5:3c19c3ae6286 | 44 | break; |
matis755 | 5:3c19c3ae6286 | 45 | } |
matis755 | 5:3c19c3ae6286 | 46 | SetTextColor(LCD_COLOR_BLACK); |
matis755 | 5:3c19c3ae6286 | 47 | for(unsigned char i=0; i<4; i++) { |
matis755 | 5:3c19c3ae6286 | 48 | DrawCircle((32 + i*58), 284, 25); |
matis755 | 5:3c19c3ae6286 | 49 | } |
matis755 | 5:3c19c3ae6286 | 50 | } |
matis755 | 5:3c19c3ae6286 | 51 | |
matis755 | 5:3c19c3ae6286 | 52 | void Gui::RefreshTop(unsigned char ucPos){ |
matis755 | 5:3c19c3ae6286 | 53 | float fAngle = (((ucPos+ucInitialPos)*pi)/24); |
matis755 | 5:3c19c3ae6286 | 54 | DrawTop(); |
matis755 | 5:3c19c3ae6286 | 55 | SetTextColor(LCD_COLOR_WHITE); |
matis755 | 5:3c19c3ae6286 | 56 | DrawLine(120, 130, 120+105*sin(fAngle), 130-105*cos(fAngle)); |
matis755 | 5:3c19c3ae6286 | 57 | } |
matis755 | 5:3c19c3ae6286 | 58 | |
matis755 | 5:3c19c3ae6286 | 59 | void Gui::SetRelAngle(unsigned char ucInitial){ |
matis755 | 5:3c19c3ae6286 | 60 | ucInitialPos = ucInitial; |
matis755 | 5:3c19c3ae6286 | 61 | } |