|
| 1 | +// |
| 2 | +// OneBitDisplay command example |
| 3 | +// shows how to create and play back a buffer of bytewise display commands |
| 4 | +// written by Larry Bank 1/23/2022 |
| 5 | +// |
| 6 | +#include <OneBitDisplay.h> |
| 7 | +OBDISP obd, obdCMD; |
| 8 | +uint8_t ucBuffer[1024], ucBackBuffer[1024]; |
| 9 | +// 16x16 X image |
| 10 | +uint8_t ucSprite[32] = {0x80,0x01,0x40,0x02,0x20,0x04,0x10,0x08, |
| 11 | + 0x08,0x10,0x04,0x20,0x02,0x40,0x01,0x80, |
| 12 | + 0x01,0x80,0x02,0x40,0x04,0x20,0x08,0x10, |
| 13 | + 0x10,0x08,0x20,0x04,0x40,0x02,0x80,0x01}; |
| 14 | +void setup() { |
| 15 | + int rc; |
| 16 | + char szTemp[32]; |
| 17 | +// int obdI2CInit(OBDISP *pOBD, int iType, int iAddr, int bFlip, int bInvert, int bWire, int iSDAPin, int iSCLPin, int iResetPin, int32_t iSpeed); |
| 18 | + rc = obdI2CInit(&obd, OLED_128x64, -1, 0, 0, 1, -1, -1, -1, 800000); |
| 19 | + obdSetBackBuffer(&obd, ucBackBuffer); |
| 20 | + obdFill(&obd, 0, 1); |
| 21 | + memset(&obdCMD, 0, sizeof(obdCMD)); // ready for commands |
| 22 | + obdSetBackBuffer(&obdCMD, ucBuffer); // give it a memory space to save the commands |
| 23 | + |
| 24 | + obdWriteString(&obd, 0,0,0, (char *)"OBD Command test", FONT_8x8, 0, 1); |
| 25 | + obdWriteString(&obd, 0,0,1, (char *)"Executing...", FONT_8x8, 0, 1); |
| 26 | + obdFill(&obdCMD, 0, 1); |
| 27 | + obdWriteString(&obdCMD, 0,0,0,(char *)"The OBD lib functions", FONT_6x8, 0, 1); |
| 28 | + obdWriteString(&obdCMD, 0,0,1,(char *)"become byte codes", FONT_6x8, 0, 1); |
| 29 | + obdWriteString(&obdCMD, 0,0,2,(char *)"written into memory", FONT_6x8, 0, 1); |
| 30 | + obdWriteString(&obdCMD, 0,0,3,(char *)"and then played back", FONT_6x8, 0, 1); |
| 31 | + obdEllipse(&obdCMD, 32, 48, 31, 15, 1, 1); |
| 32 | + obdEllipse(&obdCMD, 32, 48, 15, 12, 0, 1); |
| 33 | + obdDrawSprite(&obdCMD, ucSprite, 16, 16, 2, 96,40, 1); |
| 34 | +// obdEllipse(&obdCMD, 96, 48, 31, 15, 1, 1); |
| 35 | +// obdEllipse(&obdCMD, 96, 48, 15, 12, 0, 1); |
| 36 | + sprintf(szTemp, "%d bytes generated", obdGetCommandLen(&obdCMD)); |
| 37 | + obdWriteString(&obd, 0,0,2, szTemp, FONT_6x8, 0, 1); |
| 38 | + delay(4000); |
| 39 | + obdExecCommands(ucBuffer, obdGetCommandLen(&obdCMD), &obd, 0); |
| 40 | + obdDumpBuffer(&obd, NULL); |
| 41 | +} /* setup() */ |
| 42 | + |
| 43 | +void loop() { |
| 44 | + // put your main code here, to run repeatedly: |
| 45 | + |
| 46 | +} |
0 commit comments