MFS.h@11:aeee1b0bc033, 2021-10-12 (annotated)
- Committer:
- jack1930
- Date:
- Tue Oct 12 15:13:45 2021 +0000
- Revision:
- 11:aeee1b0bc033
- Parent:
- 8:8cbcb2364f4f
doku
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jack1930 | 11:aeee1b0bc033 | 1 | /** Library für Multifunctionshield Nucleo-F401RE |
jack1930 | 11:aeee1b0bc033 | 2 | * |
jack1930 | 11:aeee1b0bc033 | 3 | * Example: |
jack1930 | 11:aeee1b0bc033 | 4 | * @code |
jack1930 | 11:aeee1b0bc033 | 5 | * #include "MFS.h" |
jack1930 | 11:aeee1b0bc033 | 6 | * MFS mfs; |
jack1930 | 11:aeee1b0bc033 | 7 | * Ticker meinTicker; |
jack1930 | 11:aeee1b0bc033 | 8 | *void anzeigen() |
jack1930 | 11:aeee1b0bc033 | 9 | *{ |
jack1930 | 11:aeee1b0bc033 | 10 | * int ausgabe=1234; |
jack1930 | 11:aeee1b0bc033 | 11 | * |
jack1930 | 11:aeee1b0bc033 | 12 | * switch(digit) |
jack1930 | 11:aeee1b0bc033 | 13 | * { |
jack1930 | 11:aeee1b0bc033 | 14 | * case 0x10: mfs=(digit<<8)+seg7[ausgabe%10]; |
jack1930 | 11:aeee1b0bc033 | 15 | * digit=0x20; |
jack1930 | 11:aeee1b0bc033 | 16 | * break; |
jack1930 | 11:aeee1b0bc033 | 17 | * case 0x20: mfs=(digit<<8)+seg7[(ausgabe/10)%10]; |
jack1930 | 11:aeee1b0bc033 | 18 | * digit=0x40; |
jack1930 | 11:aeee1b0bc033 | 19 | * break; |
jack1930 | 11:aeee1b0bc033 | 20 | * case 0x40: mfs=(digit<<8)+seg7[(ausgabe/100)%10]; |
jack1930 | 11:aeee1b0bc033 | 21 | * digit=0x80; |
jack1930 | 11:aeee1b0bc033 | 22 | * break; |
jack1930 | 11:aeee1b0bc033 | 23 | * case 0x80: mfs=(digit<<8)+seg7[(ausgabe/1000)%10]; |
jack1930 | 11:aeee1b0bc033 | 24 | * digit=0x10; |
jack1930 | 11:aeee1b0bc033 | 25 | * break; |
jack1930 | 11:aeee1b0bc033 | 26 | * } |
jack1930 | 11:aeee1b0bc033 | 27 | *} |
jack1930 | 11:aeee1b0bc033 | 28 | * int main() { |
jack1930 | 11:aeee1b0bc033 | 29 | * //mfs=d0ss; mit d=Digit: 0b0001 Einerstelle, 0b0010 Zehnerstelle |
jack1930 | 11:aeee1b0bc033 | 30 | * // 0b0100 Hunderterstelle, 0b1000 Tausenderstelle |
jack1930 | 11:aeee1b0bc033 | 31 | * // ss Siebensegmentcode |
jack1930 | 11:aeee1b0bc033 | 32 | * while(1) { |
jack1930 | 11:aeee1b0bc033 | 33 | * } |
jack1930 | 11:aeee1b0bc033 | 34 | * } |
jack1930 | 11:aeee1b0bc033 | 35 | * @endcode |
jack1930 | 11:aeee1b0bc033 | 36 | */ |
jack1930 | 8:8cbcb2364f4f | 37 | #include "stm32f4xx_hal.h" |
jack1930 | 0:92e4253d430a | 38 | #include "mbed.h" |
jack1930 | 0:92e4253d430a | 39 | |
jack1930 | 0:92e4253d430a | 40 | #define USART_TX_Pin GPIO_PIN_2 |
jack1930 | 0:92e4253d430a | 41 | #define USART_TX_GPIO_Port GPIOA |
jack1930 | 0:92e4253d430a | 42 | #define USART_RX_Pin GPIO_PIN_3 |
jack1930 | 0:92e4253d430a | 43 | #define USART_RX_GPIO_Port GPIOA |
jack1930 | 0:92e4253d430a | 44 | #define beep_Pin GPIO_PIN_3 |
jack1930 | 0:92e4253d430a | 45 | #define beep_GPIO_Port GPIOB |
jack1930 | 0:92e4253d430a | 46 | #define latch_Pin GPIO_PIN_5 |
jack1930 | 0:92e4253d430a | 47 | #define latch_GPIO_Port GPIOB |
jack1930 | 0:92e4253d430a | 48 | |
jack1930 | 0:92e4253d430a | 49 | class MFS |
jack1930 | 0:92e4253d430a | 50 | { |
jack1930 | 0:92e4253d430a | 51 | private: |
jack1930 | 0:92e4253d430a | 52 | uint8_t dieAuswahl=0; |
jack1930 | 0:92e4253d430a | 53 | uint8_t dieSegmente=0xFF; |
jack1930 | 4:49654888d57b | 54 | char seg7[10]={0xFC,0x60,0xDA, 0xF2, 0x66, 0xB6, 0xBE, 0xE0, 0xFE, 0xF6}; |
jack1930 | 0:92e4253d430a | 55 | USART_HandleTypeDef husart1; |
jack1930 | 0:92e4253d430a | 56 | public: |
jack1930 | 1:774b96b00aed | 57 | void operator=(unsigned int wert); |
jack1930 | 5:babdf868f544 | 58 | operator int(void); |
jack1930 | 0:92e4253d430a | 59 | MFS(void); |
jack1930 | 0:92e4253d430a | 60 | void siebensegment(uint8_t wert); |
jack1930 | 0:92e4253d430a | 61 | void siebensegment(uint8_t awert,uint8_t wert); |
jack1930 | 0:92e4253d430a | 62 | void bcd(int wert); |
jack1930 | 0:92e4253d430a | 63 | void bcd(uint8_t awert, int wert); |
jack1930 | 0:92e4253d430a | 64 | void auswahl(uint8_t wert); |
jack1930 | 0:92e4253d430a | 65 | private: |
jack1930 | 0:92e4253d430a | 66 | void send(void); |
jack1930 | 0:92e4253d430a | 67 | }; |