9 #include <util/delay.h>
16 #define _P3PP_OLED_SEND_BIT(b) \
17 FastGPIO::Pin<clkPin>::setOutputValueLow(); \
19 "sbrc %2, %3\n" "sbi %0, %1\n" \
20 "sbrs %2, %3\n" "cbi %0, %1\n" \
22 "I" (FastGPIO::pinStructs[mosPin].portAddr - __SFR_OFFSET), \
23 "I" (FastGPIO::pinStructs[mosPin].bit), \
26 FastGPIO::Pin<clkPin>::setOutputValueHigh();
33 static const uint8_t clkPin = 1, mosPin = IO_D5, resPin = 0, dcPin = 17;
38 FastGPIO::Pin<clkPin>::setOutputLow();
43 FastGPIO::Pin<resPin>::setOutputLow();
45 FastGPIO::Pin<resPin>::setOutputHigh();
49 void sh1106TransferStart()
58 savedUEIENX0 = UEIENX;
61 savedStateMosi = FastGPIO::Pin<mosPin>::getState();
62 savedStateDc = FastGPIO::Pin<dcPin>::getState();
64 FastGPIO::Pin<mosPin>::setOutputLow();
67 void sh1106TransferEnd()
69 FastGPIO::Pin<mosPin>::setState(savedStateMosi);
70 FastGPIO::Pin<dcPin>::setState(savedStateDc);
74 UEIENX = savedUEIENX0;
79 void sh1106CommandMode()
81 FastGPIO::Pin<dcPin>::setOutputLow();
86 FastGPIO::Pin<dcPin>::setOutputHigh();
89 void sh1106Write(uint8_t d)
91 _P3PP_OLED_SEND_BIT(7);
92 _P3PP_OLED_SEND_BIT(6);
93 _P3PP_OLED_SEND_BIT(5);
94 _P3PP_OLED_SEND_BIT(4);
95 _P3PP_OLED_SEND_BIT(3);
96 _P3PP_OLED_SEND_BIT(2);
97 _P3PP_OLED_SEND_BIT(1);
98 _P3PP_OLED_SEND_BIT(0);
102 uint8_t savedStateMosi, savedStateDc;
103 uint8_t savedUDIEN, savedUENUM, savedUEIENX0;
Low-level functions for writing data to the SH1106 OLED on the Pololu Zumo 32U4 OLED robot.
Makes it easy to show text and graphics on the SH1106 OLED of the Pololu Zumo 32U4 OLED robot.