Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
getting ready to try fixed point math again
  • Loading branch information
mcous committed Dec 10, 2013
1 parent a824103 commit 3ee390a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
4 changes: 2 additions & 2 deletions firmware/src/clockblock.cpp
Expand Up @@ -54,14 +54,14 @@ int main(void) {

// application variables
// time vector - { seconds, minutes, hours}
uint8_t tm[3] = {0, 37, 6};
uint8_t tm[3] = {0, 0, 0};
// animation frame
uint8_t fr = 0;
// arms leds
uint16_t dots[DISPLAY_NUM_DOTS];

// initialize the LED driver
// DO THIS BEFORE RTC (to ensure proper SPI functionality for the RTC)
// DO THIS BEFORE INITIALIZING RTC (to ensure proper SPI functionality for the RTC)
tlc.init();
// set the TLC to autorepeat the pattern and to reset the GS counter whenever new data is latched in
tlc.setFC(TLC5971_DSPRPT);
Expand Down
17 changes: 7 additions & 10 deletions firmware/src/display.cpp
Expand Up @@ -163,18 +163,15 @@ void Display::displayBlend(DisplayParams p) {
// floating point + multiplication only - factors precalculated
//uint16_t hourFrac = (p.frame + (p.sec*DISPLAY_FRAMERATE) + (p.min*60*DISPLAY_FRAMERATE)) * 0.56889;
//uint16_t minFrac = (p.frame + (p.sec*DISPLAY_FRAMERATE) + (minMod*60*DISPLAY_FRAMERATE)) * 6.8267;
//uint16_t secFrac = (p.frame + (secMod*DISPLAY_FRAMERATE)) * 34.133;
//float secFrac = ((p.sec%5) + (p.frame/DISPLAY_FRAMERATE_FLOAT)) * 0.2;
//float minFrac = ((p.min%5) + ((p.sec+(p.frame/DISPLAY_FRAMERATE_FLOAT))/60))/5;
//float hourFrac = (p.frame + (DISPLAY_FRAMERATE * p.sec) + (DISPLAY_FRAMERATE*60*p.min)) * 0.00000868056;
//uint16_t secFrac = (p.frame + (secMod*DISPLAY_FRAMERATE)) * 409.59;

// attempt at fixed point and multiplication
//uint32_t hourFrac = (((p.frame + (p.sec<<5) + ((p.min*60)<<5)) << DISPLAY_LEFT_SHIFT) * DISPLAY_HOUR_SCALE);
//uint32_t minFrac = (((p.frame + (p.sec<<5) + ((minMod*60)<<5)) << DISPLAY_LEFT_SHIFT) * DISPLAY_MIN_SCALE);
//uint32_t secFrac = (((p.frame + (secMod<<5)) << DISPLAY_LEFT_SHIFT) * DISPLAY_SEC_SCALE);
//hourFrac >>= DISPLAY_RIGHT_SHIFT;
//minFrac >>= DISPLAY_RIGHT_SHIFT;
//secFrac >>= DISPLAY_RIGHT_SHIFT;
//uint32_t hourFrac = (((p.frame + (p.sec<<5) + ((p.min*60)<<5)) << DISPLAY_HOUR_L_SHIFT) * DISPLAY_HOUR_SCALE);
//uint32_t minFrac = (((p.frame + (p.sec<<5) + ((minMod*60)<<5)) << DISPLAY_MIN_L_SHIFT) * DISPLAY_MIN_SCALE);
//uint32_t secFrac = (((p.frame + (secMod<<5)) << DISPLAY_SEC_L_SHIFT) * DISPLAY_SEC_SCALE);
//hourFrac >>= DISPLAY_HOUR_R_SHIFT;
//minFrac >>= DISPLAY_MIN_R_SHIFT;
//secFrac >>= DISPLAY_SEC_R_SHIFT;


// fill the hour dots
Expand Down
29 changes: 24 additions & 5 deletions firmware/src/display.h
Expand Up @@ -22,11 +22,30 @@
#define DISPLAY_FRAMERATE_FLOAT 32.0

// fixed point scaling factors
#define DISPLAY_HOUR_SCALE 146
#define DISPLAY_MIN_SCALE 1747
#define DISPLAY_SEC_SCALE 104857
#define DISPLAY_LEFT_SHIFT 8
#define DISPLAY_RIGHT_SHIFT 16
// hours
// - fixed point factor: 2^8
// - scale = (((# of seconds in an hour)*(framerate))/(led levels)) * fixed point factor
// - = ((60*60*32)/65536) * 256
//#define DISPLAY_HOUR_FACTOR 256
#define DISPLAY_HOUR_SCALE 146
#define DISPLAY_HOUR_L_SHIFT 8
#define DISPLAY_HOUR_R_SHIFT 16
// minutes
// - fixed point factor: 2^4
// - scale = ((# of seconds in 5 minutes)*(framerate))/(led levels)) * fixed point factor
// - = ((60*5*32)/65536) * 16
//#define DISPLAY_MIN_FACTOR 16
#define DISPLAY_MIN_SCALE 109
#define DISPLAY_MIN_L_SHIFT 4
#define DISPLAY_MIN_R_SHIFT 8
// seconds
// - fixed point factor: 2^0
// - scale = ((5 seconds)*(framerate))/(led levels)) * fixed point factor
// - = ((5*32)/65536) * 1
//#define DISPLAY_SEC_FACTOR 1
#define DISPLAY_SEC_SCALE 409
#define DISPLAY_SEC_L_SHIFT 0
#define DISPLAY_SEC_R_SHIFT 0

// effect modes
#define DISPLAY_NUM_MODES 2
Expand Down

0 comments on commit 3ee390a

Please sign in to comment.