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();
36 static const uint8_t clkPin = 1, mosPin = IO_D5, resPin = 0, dcPin = 17;
41 FastGPIO::Pin<clkPin>::setOutputLow();
46 FastGPIO::Pin<resPin>::setOutputLow();
48 FastGPIO::Pin<resPin>::setOutputHigh();
52 void sh1106TransferStart()
61 savedUEIENX0 = UEIENX;
64 savedStateMosi = FastGPIO::Pin<mosPin>::getState();
65 savedStateDc = FastGPIO::Pin<dcPin>::getState();
67 FastGPIO::Pin<mosPin>::setOutputLow();
70 void sh1106TransferEnd()
72 FastGPIO::Pin<mosPin>::setState(savedStateMosi);
73 FastGPIO::Pin<dcPin>::setState(savedStateDc);
77 UEIENX = savedUEIENX0;
82 void sh1106CommandMode()
84 FastGPIO::Pin<dcPin>::setOutputLow();
89 FastGPIO::Pin<dcPin>::setOutputHigh();
92 void sh1106Write(uint8_t d)
94 _P3PP_OLED_SEND_BIT(7);
95 _P3PP_OLED_SEND_BIT(6);
96 _P3PP_OLED_SEND_BIT(5);
97 _P3PP_OLED_SEND_BIT(4);
98 _P3PP_OLED_SEND_BIT(3);
99 _P3PP_OLED_SEND_BIT(2);
100 _P3PP_OLED_SEND_BIT(1);
101 _P3PP_OLED_SEND_BIT(0);
105 uint8_t savedStateMosi, savedStateDc;
106 uint8_t savedUDIEN, savedUENUM, savedUEIENX0;
Low-level functions for writing data to the SH1106 OLED on the Pololu 3pi+ 32U4 OLED robot.
Makes it easy to show text and graphics on the SH1106 OLED of the Pololu 3pi+ 32U4 OLED robot.
Top-level namespace for the Pololu3piPlus32U4 library.