SharpDumpBuffer() */ Dump a screen's worth of data directly to the display Try to speed it up by comparing the new bytes with the existing buffer
| 789 | // Try to speed it up by comparing the new bytes with the existing buffer |
| 790 | // |
| 791 | void obdDumpBuffer(OBDISP *pOBD, uint8_t *pBuffer) |
| 792 | { |
| 793 | int x, y, iPitch; |
| 794 | int iLines, iCols; |
| 795 | uint8_t bNeedPos; |
| 796 | uint8_t *pSrc = pOBD->ucScreen; |
| 797 | |
| 798 | iPitch = pOBD->width; |
| 799 | if (pOBD->type == LCD_VIRTUAL) // wrong function for this type of display |
| 800 | return; |
| 801 | if (pBuffer == NULL) // dump the internal buffer if none is given |
| 802 | pBuffer = pOBD->ucScreen; |
| 803 | if (pBuffer == NULL) |
| 804 | return; // no backbuffer and no provided buffer |
| 805 | |
| 806 | if (pOBD->type >= SHARP_144x168) // special case for Sharp Memory LCD |
| 807 | { |
| 808 | SharpDumpBuffer(pOBD, pBuffer); |
| 809 | return; |
| 810 | } |
| 811 | iLines = pOBD->height >> 3; |
| 812 | iCols = pOBD->width >> 4; |
| 813 | for (y = 0; y < iLines; y++) |
| 814 | { |
| 815 | bNeedPos = 1; // start of a new line means we need to set the position too |
| 816 | for (x = 0; x < iCols; x++) // wiring library has a 32-byte buffer, so send 16 bytes so that the data prefix (0x40) can fit |
| 817 | { |
| 818 | if (pOBD->ucScreen == NULL || pBuffer == pSrc || memcmp(pSrc, pBuffer, 16) != 0) // doesn't match, need to send it |
| 819 | { |
| 820 | if (bNeedPos) // need to reposition output cursor? |
| 821 | { |
| 822 | bNeedPos = 0; |
| 823 | obdCachedFlush(pOBD, 1); |
| 824 | obdSetPosition(pOBD, x * 16, y, 1); |
| 825 | } |
| 826 | obdCachedWrite(pOBD, pBuffer, 16, 1); |
| 827 | } |
| 828 | else |
| 829 | { |
| 830 | bNeedPos = 1; // we're skipping a block, so next time will need to set the new position |
| 831 | } |
| 832 | pSrc += 16; |
| 833 | pBuffer += 16; |
| 834 | } // for x |
| 835 | pSrc += (iPitch - pOBD->width); // for narrow displays, skip to the next line |
| 836 | pBuffer += (iPitch - pOBD->width); |
| 837 | } // for y |
| 838 | obdCachedFlush(pOBD, 1); |
| 839 | } /* obdDumpBuffer() */ |
| 840 | |
| 841 | // A valid CW or CCW move returns 1 or -1, invalid returns 0. |
| 842 | static int obdMenuReadRotary(SIMPLEMENU *sm) |
no test coverage detected