You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.2 KiB

  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdio.h>
  4. #include "action.h"
  5. enum ssd1306_cmds {
  6. DisplayOff = 0xAE,
  7. DisplayOn = 0xAF,
  8. SetContrast = 0x81,
  9. DisplayAllOnResume = 0xA4,
  10. DisplayAllOn = 0xA5,
  11. NormalDisplay = 0xA6,
  12. InvertDisplay = 0xA7,
  13. SetDisplayOffset = 0xD3,
  14. SetComPins = 0xda,
  15. SetVComDetect = 0xdb,
  16. SetDisplayClockDiv = 0xD5,
  17. SetPreCharge = 0xd9,
  18. SetMultiPlex = 0xa8,
  19. SetLowColumn = 0x00,
  20. SetHighColumn = 0x10,
  21. SetStartLine = 0x40,
  22. SetMemoryMode = 0x20,
  23. ColumnAddr = 0x21,
  24. PageAddr = 0x22,
  25. ComScanInc = 0xc0,
  26. ComScanDec = 0xc8,
  27. SegRemap = 0xa0,
  28. SetChargePump = 0x8d,
  29. ExternalVcc = 0x01,
  30. SwitchCapVcc = 0x02,
  31. ActivateScroll = 0x2f,
  32. DeActivateScroll = 0x2e,
  33. SetVerticalScrollArea = 0xa3,
  34. RightHorizontalScroll = 0x26,
  35. LeftHorizontalScroll = 0x27,
  36. VerticalAndRightHorizontalScroll = 0x29,
  37. VerticalAndLeftHorizontalScroll = 0x2a,
  38. };
  39. // Controls the SSD1306 128x32 OLED display via i2c
  40. #ifndef SSD1306_ADDRESS
  41. #define SSD1306_ADDRESS 0x3C
  42. #endif
  43. #ifdef SSD1306_128X64
  44. #define DisplayHeight 64
  45. #else
  46. #define DisplayHeight 32
  47. #endif
  48. #define DisplayWidth 128
  49. #define FontHeight 8
  50. #define FontWidth 6
  51. #define MatrixRows (DisplayHeight / FontHeight)
  52. #define MatrixCols (DisplayWidth / FontWidth)
  53. struct CharacterMatrix {
  54. uint8_t display[MatrixRows][MatrixCols];
  55. uint8_t *cursor;
  56. bool dirty;
  57. };
  58. extern struct CharacterMatrix display;
  59. bool iota_gfx_init(bool rotate);
  60. void iota_gfx_task(void);
  61. bool iota_gfx_off(void);
  62. bool iota_gfx_on(void);
  63. void iota_gfx_flush(void);
  64. void iota_gfx_write_char(uint8_t c);
  65. void iota_gfx_write(const char *data);
  66. void iota_gfx_write_P(const char *data);
  67. void iota_gfx_clear_screen(void);
  68. void iota_gfx_task_user(void);
  69. void matrix_clear(struct CharacterMatrix *matrix);
  70. void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c);
  71. void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c);
  72. void matrix_write(struct CharacterMatrix *matrix, const char *data);
  73. void matrix_write_ln(struct CharacterMatrix *matrix, const char *data);
  74. void matrix_write_P(struct CharacterMatrix *matrix, const char *data);
  75. void matrix_render(struct CharacterMatrix *matrix);
  76. bool process_record_gfx(uint16_t keycode, keyrecord_t *record);