Princeton PT6964 LED controller supports 4 Digits @ 13 Segments, 5 Digits @ 12 Segments, 6 Digits @ 11 Segments or 7 Digits @ 10 Segments. Also supports a scanned keyboard of upto 20 keys. SPI bus interface.
Princeton PT6964 LED controller supports 4 Digits @ 13 Segments, 5 Digits @ 12 Segments, 6 Digits @ 11 Segments or 7 Digits @ 10 Segments. Also supports a scanned keyboard of upto 20 keys. SPI bus interface.
See Component page here.
Diff: PT6964.cpp
- Revision:
- 2:eaf2f5d1af34
- Parent:
- 1:1adf993a3e34
--- a/PT6964.cpp Sat Jan 09 13:40:06 2016 +0000 +++ b/PT6964.cpp Thu Jan 14 20:09:52 2016 +0000 @@ -2,6 +2,7 @@ * Copyright (c) 2015, v01: WH, Initial version * 2015, v02: WH, rename Digit/Grid * 2016, v03: WH, updated Icon handling, UDCs and _putc() + * 2016, v04: WH, Refactored display and keyboard defines * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -166,8 +167,9 @@ for (int idx=0; idx < PT6964_KEY_MEM; idx++) { data = _flip(_spi.write(0xFF)); // read keys and correct bitorder + data = data & PT6964_KEY_MSK; // Mask valid bits if (data != 0) { // Check for any pressed key - for (int bit=0; bit < PT6964_KEY_BITS; bit++) { + for (int bit=0; bit < 8; bit++) { if (data & (1 << bit)) {keypress++;} // Test all significant bits } } @@ -287,7 +289,7 @@ if (clrAll) { //clear local buffer (including Icons) - for (int idx=0; idx < (DVD538A_NR_GRIDS << 1); idx++) { + for (int idx=0; idx < (DVD538A_NR_GRIDS << 1); idx++) { // * PT6964_BYTES_PER_GRID _displaybuffer[idx] = 0x00; } } @@ -299,7 +301,7 @@ } } - writeData(_displaybuffer, (DVD538A_NR_GRIDS*2)); + writeData(_displaybuffer, (DVD538A_NR_GRIDS * PT6964_BYTES_PER_GRID)); _column = 0; } @@ -315,12 +317,12 @@ icn = icon & 0xFFFF; addr = (icon >> 24) & 0xFF; - addr = (addr - 1) << 1; + addr = (addr - 1) << 1; // * PT6964_BYTES_PER_GRID //Save char...and set bits for icon to write _displaybuffer[addr] = _displaybuffer[addr] | LO(icn); _displaybuffer[addr+1] = _displaybuffer[addr+1] | HI(icn); - writeData(_displaybuffer, (DVD538A_NR_GRIDS*2)); + writeData(_displaybuffer, (DVD538A_NR_GRIDS * PT6964_BYTES_PER_GRID)); } /** Clr Icon @@ -333,12 +335,12 @@ icn = icon & 0xFFFF; addr = (icon >> 24) & 0xFF; - addr = (addr - 1) << 1; + addr = (addr - 1) << 1; // * PT6964_BYTES_PER_GRID //Save char...and clr bits for icon to write _displaybuffer[addr] = _displaybuffer[addr] & ~LO(icn); _displaybuffer[addr+1] = _displaybuffer[addr+1] & ~HI(icn); - writeData(_displaybuffer, (DVD538A_NR_GRIDS*2)); + writeData(_displaybuffer, (DVD538A_NR_GRIDS * PT6964_BYTES_PER_GRID)); } @@ -407,13 +409,13 @@ //_column == 1 => Grid4 => addr = 6 //_column == 2 => Grid3 => addr = 4 //_column == 3 => Grid4 => addr = 2 - addr = (4 - _column) << 1; + addr = (4 - _column) << 1; // * PT6964_BYTES_PER_GRID //Save icons...and set bits for character to write _displaybuffer[addr] = (_displaybuffer[addr] & MASK_ICON_GRID[4 - _column][0]) | LO(pattern); _displaybuffer[addr+1] = (_displaybuffer[addr+1] & MASK_ICON_GRID[4 - _column][1]) | HI(pattern); - writeData(_displaybuffer, (DVD538A_NR_GRIDS*2)); + writeData(_displaybuffer, (DVD538A_NR_GRIDS * PT6964_BYTES_PER_GRID)); //Update Cursor _column++;