Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SD600A by
Diff: SD600A.cpp
- Revision:
- 10:d2dd5c752f7b
- Parent:
- 9:f90196d36597
- Child:
- 11:97ef14b4c4de
diff -r f90196d36597 -r d2dd5c752f7b SD600A.cpp
--- a/SD600A.cpp Wed Oct 10 03:21:16 2012 +0000
+++ b/SD600A.cpp Wed Oct 10 03:57:16 2012 +0000
@@ -55,8 +55,10 @@
void SD600A::write(uint8_t byte) {
for (int i=0; i<8; i++) {
+ dat = !!(byte & (1 << (7 - i)));
+
clk = 1;
- dat = (byte & 0x80);
+ // dat = (byte & 0x80);
#ifdef DELAY_PERIOD
wait_us(DELAY_PERIOD);
#endif
@@ -64,12 +66,11 @@
#ifdef DELAY_PERIOD
wait_us(DELAY_PERIOD);
#endif
- byte <<= 1;
+ //byte <<= 1;
}
}
void SD600A::begin(void) {
-
// Issue initial latch to 'wake up' strip (latch length varies w/numLEDs)
threadlock.lock();
for (int i=0; i<numLEDs; i++) {
@@ -86,12 +87,12 @@
}
void SD600A::writeguard(void) {
- // generate a 25-bit word of zeros
+ // generate a 25-bit word of ones
clk = 1;
#ifdef DELAY_PERIOD
wait_us(DELAY_PERIOD);
#endif
- dat = 1;
+ dat = 0;
#ifdef DELAY_PERIOD
wait_us(DELAY_PERIOD);
#endif
@@ -128,29 +129,29 @@
// Convert R,G,B to combined 32-bit color
uint32_t SD600A::Color(uint8_t r, uint8_t g, uint8_t b) {
// Take 23 bits of the value and append them end to end
- // We cannot drive all ones or it will make the part latch if the previous word ended in zero!
- return 0xfffffe & ((uint32_t)g << 16) | ((uint32_t)r << 8) | (uint32_t)b;
+ // We cannot drive all ones or it will make the part latch if the previous word ended in one!
+ return 0xfefefe & ((uint32_t)g << 16) | ((uint32_t)r << 8) | (uint32_t)b;
}
// store the rgb component in our array
void SD600A::setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b) {
if (n >= numLEDs) return; // '>=' because arrays are 0-indexed
- pixels[n*3 ] = g & 0xff;
- pixels[n*3+1] = r & 0xff;
+ pixels[n*3 ] = g & 0xfe;
+ pixels[n*3+1] = r & 0xfe;
pixels[n*3+2] = b & 0xfe;
}
void SD600A::setPixelR(uint16_t n, uint8_t r) {
if (n >= numLEDs) return; // '>=' because arrays are 0-indexed
- pixels[n*3+1] = r & 0xff;
+ pixels[n*3+1] = r & 0xfe;
}
void SD600A::setPixelG(uint16_t n, uint8_t g) {
if (n >= numLEDs) return; // '>=' because arrays are 0-indexed
- pixels[n*3] = g & 0xff;
+ pixels[n*3] = g & 0xfe;
}
void SD600A::setPixelB(uint16_t n, uint8_t b) {
@@ -162,7 +163,7 @@
void SD600A::setPixelColor(uint16_t n, uint32_t c) {
if (n >= numLEDs) return; // '>=' because arrays are 0-indexed
- pixels[n*3 ] = (c >> 16) & 0xff;
- pixels[n*3+1] = (c >> 8) & 0xff;
+ pixels[n*3 ] = (c >> 16) & 0xfe;
+ pixels[n*3+1] = (c >> 8) & 0xfe;
pixels[n*3+2] = c & 0xfe;
}
