diff options
Diffstat (limited to 'drivers/avr/ssd1306.h')
| -rw-r--r-- | drivers/avr/ssd1306.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/drivers/avr/ssd1306.h b/drivers/avr/ssd1306.h index b0c74f987..1b6f8a493 100644 --- a/drivers/avr/ssd1306.h +++ b/drivers/avr/ssd1306.h | |||
| @@ -3,6 +3,71 @@ | |||
| 3 | 3 | ||
| 4 | #include <stdbool.h> | 4 | #include <stdbool.h> |
| 5 | #include <stdio.h> | 5 | #include <stdio.h> |
| 6 | #include "pincontrol.h" | ||
| 7 | #include "config.h" | ||
| 8 | |||
| 9 | enum ssd1306_cmds { | ||
| 10 | DisplayOff = 0xAE, | ||
| 11 | DisplayOn = 0xAF, | ||
| 12 | |||
| 13 | SetContrast = 0x81, | ||
| 14 | DisplayAllOnResume = 0xA4, | ||
| 15 | |||
| 16 | DisplayAllOn = 0xA5, | ||
| 17 | NormalDisplay = 0xA6, | ||
| 18 | InvertDisplay = 0xA7, | ||
| 19 | SetDisplayOffset = 0xD3, | ||
| 20 | SetComPins = 0xda, | ||
| 21 | SetVComDetect = 0xdb, | ||
| 22 | SetDisplayClockDiv = 0xD5, | ||
| 23 | SetPreCharge = 0xd9, | ||
| 24 | SetMultiPlex = 0xa8, | ||
| 25 | SetLowColumn = 0x00, | ||
| 26 | SetHighColumn = 0x10, | ||
| 27 | SetStartLine = 0x40, | ||
| 28 | |||
| 29 | SetMemoryMode = 0x20, | ||
| 30 | ColumnAddr = 0x21, | ||
| 31 | PageAddr = 0x22, | ||
| 32 | |||
| 33 | ComScanInc = 0xc0, | ||
| 34 | ComScanDec = 0xc8, | ||
| 35 | SegRemap = 0xa0, | ||
| 36 | SetChargePump = 0x8d, | ||
| 37 | ExternalVcc = 0x01, | ||
| 38 | SwitchCapVcc = 0x02, | ||
| 39 | |||
| 40 | ActivateScroll = 0x2f, | ||
| 41 | DeActivateScroll = 0x2e, | ||
| 42 | SetVerticalScrollArea = 0xa3, | ||
| 43 | RightHorizontalScroll = 0x26, | ||
| 44 | LeftHorizontalScroll = 0x27, | ||
| 45 | VerticalAndRightHorizontalScroll = 0x29, | ||
| 46 | VerticalAndLeftHorizontalScroll = 0x2a, | ||
| 47 | }; | ||
| 48 | |||
| 49 | // Controls the SSD1306 128x32 OLED display via i2c | ||
| 50 | |||
| 51 | #ifndef SSD1306_ADDRESS | ||
| 52 | #define SSD1306_ADDRESS 0x3C | ||
| 53 | #endif | ||
| 54 | |||
| 55 | #define DisplayHeight 32 | ||
| 56 | #define DisplayWidth 128 | ||
| 57 | |||
| 58 | #define FontHeight 8 | ||
| 59 | #define FontWidth 6 | ||
| 60 | |||
| 61 | #define MatrixRows (DisplayHeight / FontHeight) | ||
| 62 | #define MatrixCols (DisplayWidth / FontWidth) | ||
| 63 | |||
| 64 | struct CharacterMatrix { | ||
| 65 | uint8_t display[MatrixRows][MatrixCols]; | ||
| 66 | uint8_t *cursor; | ||
| 67 | bool dirty; | ||
| 68 | }; | ||
| 69 | |||
| 70 | struct CharacterMatrix display; | ||
| 6 | 71 | ||
| 7 | bool iota_gfx_init(void); | 72 | bool iota_gfx_init(void); |
| 8 | void iota_gfx_task(void); | 73 | void iota_gfx_task(void); |
| @@ -14,4 +79,16 @@ void iota_gfx_write(const char *data); | |||
| 14 | void iota_gfx_write_P(const char *data); | 79 | void iota_gfx_write_P(const char *data); |
| 15 | void iota_gfx_clear_screen(void); | 80 | void iota_gfx_clear_screen(void); |
| 16 | 81 | ||
| 82 | __attribute__((weak)) | ||
| 83 | void iota_gfx_task_user(void); | ||
| 84 | |||
| 85 | void matrix_clear(struct CharacterMatrix *matrix); | ||
| 86 | void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c); | ||
| 87 | void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c); | ||
| 88 | void matrix_write(struct CharacterMatrix *matrix, const char *data); | ||
| 89 | void matrix_write_P(struct CharacterMatrix *matrix, const char *data); | ||
| 90 | void matrix_render(struct CharacterMatrix *matrix); | ||
| 91 | |||
| 92 | |||
| 93 | |||
| 17 | #endif | 94 | #endif |
