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.

90 lines
2.2 KiB

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