void Max7219::doScrollUp() { byte i = 0; for(; i < 7; ++i) { scrollChar[i] = scrollChar[i + 1]; maxSingle(i + 1, scrollChar[i]); } word charOffset = getCharOffset(pgm_read_byte_near(m_scrollText + m_scrollIndex)) + m_currScrollPixRowCol; byte row = pgm_read_byte_near(parallax_font + charOffset); scrollChar[i] = m_inverseScroll ? ~row : row; maxSingle(i + 1, scrollChar[i]); scrollNextPixRowCol(); } // doScrollUp
void Max7219::resetPercentage(unsigned int maxValue) { m_percentMaxValue = maxValue; m_percentLastValue = 0; for(byte i = 1; i <= 8; ++i) maxSingle(i, 0); } // resetPercentage
void Max7219::showPercentage(unsigned int current) { byte numLedsHigh = (byte)(64l * current / m_percentMaxValue); // no need to update if resulting in same amount of lit leds. if(numLedsHigh == m_percentLastValue) return; // remember it. m_percentLastValue = numLedsHigh; byte row = 1; // // don't process rows already lit. // while(numLedsHigh > 8) { // row++; // numLedsHigh -= 8; // } // now update the remaining leds on the current row. while(0 not_eq numLedsHigh) { maxSingle(row++, numLedsHigh < 8 ? pgm_read_byte_near(ledBitArray + numLedsHigh) : 255); if(numLedsHigh >= 8) numLedsHigh -= 8; else numLedsHigh = 0; } } // showPercentage
void Max7219::setToCharacter(byte character, boolean inverse) const { word charOffset = getCharOffset(character); for(byte i = 0; i < 8; ++i) { byte val = pgm_read_byte_near(parallax_font + charOffset++); maxSingle(i + 1, inverse ? ~val : val); } } // setChar
static void maxSingle(const uint8_t *p) { if (p != NULL) { //Serial.println("DotMatrix ON"); for(U8 i=1; i<=8; ++i) { maxSingle(i, pgm_read_byte(p++)); } } else { //Serial.println("DotMatrix OFF"); for(U8 i=1; i<=8; ++i) { maxSingle(i, 0); } } }
void MAX::f(int time) { maxSingle(1,0); maxSingle(2,127); maxSingle(3,127); maxSingle(4,9); maxSingle(5,9); maxSingle(6,1); maxSingle(7,1); maxSingle(8,0); delay(time); }
void MAX::a(int time) { maxSingle(1,0); maxSingle(2,124); maxSingle(3,126); maxSingle(4,11); maxSingle(5,11); maxSingle(6,126); maxSingle(7,124); maxSingle(8,0); delay(time); }
void MAX::g(int time) { maxSingle(1,0); maxSingle(2,62); maxSingle(3,123); maxSingle(4,65); maxSingle(5,73); maxSingle(6,123); maxSingle(7,58); maxSingle(8,0); delay(time); }
void MAX::e(int time) { maxSingle(1,0); maxSingle(2,127); maxSingle(3,127); maxSingle(4,73); maxSingle(5,73); maxSingle(6,65); maxSingle(7,65); maxSingle(8,0); delay(time); }
void MAX::d(int time) { maxSingle(1,0); maxSingle(2,127); maxSingle(3,127); maxSingle(4,65); maxSingle(5,99); maxSingle(6,62); maxSingle(7,28); maxSingle(8,0); delay(time); }
void MAX::c(int time) { maxSingle(1,0); maxSingle(2,62); maxSingle(3,127); maxSingle(4,65); maxSingle(5,65); maxSingle(6,99); maxSingle(7,34); maxSingle(8,0); delay(time); }
// Cmd static void DotMatrix_Cmd(U8 Digit = FONT_DIGIT_RESET, U16 SetTimer = IR_CAR_DOTMATRIX_AUTO_STOP, bool SetFlash = false) { // Timer Reset DotMatrix_TimerON = 0; DotMatrix_Flash_Timer = 0; // Set ? if ((Digit < FONT_DIGIT_NUMBER) && (IRCar_Power_OK) && (IRCar_Battery_LipoDetected)) { maxSingle(Font_Digit[Digit]); // Update Global Time IRCar_TimeMs = millis(); // Set Timer (if asked) DotMatrix_Timer_Duration = SetTimer; if (SetTimer > 0) { DotMatrix_TimerON = IRCar_TimeMs; // no null Timer => reserved for stopped state if (!DotMatrix_TimerON) DotMatrix_TimerON = 1; } // Set Flash (is asker) if (SetFlash) { DotMatrix_Flash_Timer = IRCar_TimeMs; // no null Timer => reserved for stopped state if (!DotMatrix_Flash_Timer) DotMatrix_Flash_Timer = 1; // save current digit DotMatrix_Flash_Digit = Digit; DotMatrix_Flash_State = true; } } // Reset ? else { maxSingle(NULL); } }
// Process void IRCar_DotMatrix_Process(void) { // Power Issue ? if (!IRCar_Power_OK) { DotMatrix_Cmd(); return; } // Execute if (DotMatrix_TimerON && ((IRCar_TimeMs - DotMatrix_TimerON) >= DotMatrix_Timer_Duration)) { DotMatrix_Cmd(); } else if (DotMatrix_Flash_Timer && ((IRCar_TimeMs - DotMatrix_Flash_Timer) >= IR_CAR_DOTMATRIX_FLASH_PERIOD)) { // re-arm flash timer DotMatrix_Flash_Timer = IRCar_TimeMs; if (!DotMatrix_Flash_Timer) DotMatrix_Flash_Timer = 1; // re-draw if (DotMatrix_Flash_State) { DotMatrix_Flash_State = false; maxSingle(NULL); } else { DotMatrix_Flash_State = true; if ((DotMatrix_Flash_Digit < FONT_DIGIT_NUMBER) && (IRCar_Power_OK) && (IRCar_Battery_LipoDetected)) { maxSingle(Font_Digit[DotMatrix_Flash_Digit]); } } } }
void MAX::scrllD(int num, int time) { int dill[8] = {1, 2, 3, 4, 5, 6, 7, 8}; for ( int n = 1; n <= (num*8)+1; n++) { //Displaying character based on values in dill array maxSingle(dill[0],0); maxSingle(dill[1],127); maxSingle(dill[2],127); maxSingle(dill[3],65); maxSingle(dill[4],99); maxSingle(dill[5],62); maxSingle(dill[6],28); maxSingle(dill[7],0); //Shifting vales in dill array one to the left rotateLeft(dill,8); delay(time); } }
void Max7219::doScrollLeft() { // scroll the current char. word theChar = pgm_read_byte_near(m_scrollText + m_scrollIndex); if(theChar >= 64) theChar -= 64; word charOffset = theChar * 8; for(byte i = 0; i < 8; ++i) { scrollChar[i] <<= 1; boolean bitset = (pgm_read_byte_near(parallax_font + charOffset++) bitand (1 << (7 - m_currScrollPixRowCol))) not_eq 0; if(m_inverseScroll) bitset ^= true; scrollChar[i] or_eq bitset ? (1 << 0) : 0; maxSingle(i + 1, scrollChar[i]); } scrollNextPixRowCol(); } // doScrollLeft
void Max7219::fill(byte pattern) const { for(byte i = 1; i < 8; ++i) maxSingle(1, pattern); } // fill
void MAX::test(int time) { maxSingle(1,255); maxSingle(2,255); maxSingle(3,255); maxSingle(4,255); maxSingle(5,255); maxSingle(6,255); maxSingle(7,255); maxSingle(8,255); delay(time); maxSingle(1,0); maxSingle(2,0); maxSingle(3,0); maxSingle(4,0); maxSingle(5,0); maxSingle(6,0); maxSingle(7,0); maxSingle(8,0); delay(time); }