|
@@ -1,7 +1,7 @@
|
|
|
/**
|
|
|
- * My Nixie Clock IN-12
|
|
|
+ * My Nixie Clock IN-4x6
|
|
|
* Vladimir N. Shilov <shilow@ukr.net>
|
|
|
- * 2019.01.18
|
|
|
+ * 2020.01.06
|
|
|
*/
|
|
|
/* Compiler libs */
|
|
|
#include <stdbool.h>
|
|
@@ -62,16 +62,16 @@ static struct {
|
|
|
|
|
|
|
|
|
/* Variables */
|
|
|
-static volatile uint8_t Digit[4] = {1, 2, 3, 4};
|
|
|
+static volatile uint8_t Digit[6] = {1, 2, 3, 4, 5, 6};
|
|
|
static rtc_t RTC, setRTC;
|
|
|
static volatile struct {
|
|
|
uint8_t RTC_Int: 1;
|
|
|
uint8_t saveCal: 1;
|
|
|
- uint8_t blinkC: 1;
|
|
|
- uint8_t blink0: 1;
|
|
|
- uint8_t blink1: 1;
|
|
|
- uint8_t blink2: 1;
|
|
|
- uint8_t blink3: 1;
|
|
|
+ uint8_t blinkC: 1; // флаг задающий ритм мигания
|
|
|
+ uint8_t blink0: 1; // мигать разрядами 1-2
|
|
|
+ uint8_t blink1: 1; // мигать разрядами 3-4
|
|
|
+ uint8_t blink2: 1; // мигать разрядами 5-6
|
|
|
+ uint8_t rezerv: 1;
|
|
|
uint8_t saveEEP: 1;
|
|
|
} Flag;
|
|
|
static btn_t Button[BTN_NUM] = {
|
|
@@ -114,7 +114,6 @@ void main(void) {
|
|
|
Flag.blink0 = 0;
|
|
|
Flag.blink1 = 0;
|
|
|
Flag.blink2 = 0;
|
|
|
- Flag.blink3 = 0;
|
|
|
Flag.blinkC = 0;
|
|
|
Flag.saveEEP = 0;
|
|
|
|
|
@@ -132,6 +131,7 @@ void main(void) {
|
|
|
|
|
|
/* Initialize Scheduler */
|
|
|
RTOS_Init();
|
|
|
+ tdelay_ms(10000);
|
|
|
|
|
|
/* Initialize I2C Bus and RTC */
|
|
|
I2C_Init();
|
|
@@ -236,9 +236,10 @@ static void Board_Init(void) {
|
|
|
ACSR = ACD;
|
|
|
|
|
|
/* GPIO */
|
|
|
+ DDRB = ANODB_PINS; // as output
|
|
|
PORTB = BUTTON_PINS; // enable pull-up
|
|
|
DDRC = DIGIT_PINS; // as output
|
|
|
- DDRD = (DOT_PIN | ANOD_PINS); // as output
|
|
|
+ DDRD = (DOT_PIN | ANODD_PINS); // as output
|
|
|
|
|
|
#ifdef USE_DHT
|
|
|
/* Timer1, IC negative edge, CTC mode, 64 prescaler, 4 mks one tick */
|
|
@@ -470,6 +471,8 @@ void showTime(void) {
|
|
|
Digit[1] = RTC.Hr & 0x0F;
|
|
|
Digit[2] = RTC.Min >> 4;
|
|
|
Digit[3] = RTC.Min & 0x0F;
|
|
|
+ Digit[4] = RTC.Sec >> 4;
|
|
|
+ Digit[5] = RTC.Sec & 0x0F;
|
|
|
}
|
|
|
|
|
|
void showMMSS(void) {
|
|
@@ -628,9 +631,8 @@ void setTimeBegin(void) {
|
|
|
|
|
|
void setHHBegin(void) {
|
|
|
Flag.blink0 = 1;
|
|
|
- Flag.blink1 = 1;
|
|
|
+ Flag.blink1 = 0;
|
|
|
Flag.blink2 = 0;
|
|
|
- Flag.blink3 = 0;
|
|
|
RTOS_SetTask(blink, 0, 0);
|
|
|
setTimeShow();
|
|
|
}
|
|
@@ -645,9 +647,8 @@ void setHHDec(void) {
|
|
|
|
|
|
void setMMBegin(void) {
|
|
|
Flag.blink0 = 0;
|
|
|
- Flag.blink1 = 0;
|
|
|
- Flag.blink2 = 1;
|
|
|
- Flag.blink3 = 1;
|
|
|
+ Flag.blink1 = 1;
|
|
|
+ Flag.blink2 = 0;
|
|
|
RTOS_SetTask(blink, 0, 0);
|
|
|
setTimeShow();
|
|
|
}
|
|
@@ -670,7 +671,6 @@ void setTimeEnd(void) {
|
|
|
Flag.blink0 = 0;
|
|
|
Flag.blink1 = 0;
|
|
|
Flag.blink2 = 0;
|
|
|
- Flag.blink3 = 0;
|
|
|
Flag.blinkC = 0;
|
|
|
|
|
|
RTC_ReadTime(&RTC);
|
|
@@ -745,11 +745,13 @@ ISR(TIMER2_OVF_vect) {
|
|
|
TCNT2 = TIMER2_CNT;
|
|
|
|
|
|
// read current register value and clean bits
|
|
|
- uint8_t pd = PORTD & ~ANOD_PINS;
|
|
|
+ uint8_t pb = PORTB & ~ANODB_PINS;
|
|
|
+ uint8_t pd = PORTD & ~ANODD_PINS;
|
|
|
uint8_t pc = PORTC & ~DIGIT_PINS;
|
|
|
|
|
|
#ifndef USE_BRIGHT_CONTROL
|
|
|
// power off lamps
|
|
|
+ PORTB = pb;
|
|
|
PORTD = pd;
|
|
|
PORTC = pc;
|
|
|
#endif
|
|
@@ -770,7 +772,7 @@ ISR(TIMER2_OVF_vect) {
|
|
|
case 1:
|
|
|
PORTC = pc | Digit[1];
|
|
|
if (Digit[1] != DIGIT_BLANK) {
|
|
|
- if (Flag.blink1 == 0 || Flag.blinkC == 0) {
|
|
|
+ if (Flag.blink0 == 0 || Flag.blinkC == 0) {
|
|
|
PORTD = pd | ANOD2;
|
|
|
}
|
|
|
}
|
|
@@ -780,7 +782,7 @@ ISR(TIMER2_OVF_vect) {
|
|
|
case 2:
|
|
|
PORTC = pc | Digit[2];
|
|
|
if (Digit[2] != DIGIT_BLANK) {
|
|
|
- if (Flag.blink2 == 0 || Flag.blinkC == 0) {
|
|
|
+ if (Flag.blink1 == 0 || Flag.blinkC == 0) {
|
|
|
PORTD = pd | ANOD3;
|
|
|
}
|
|
|
}
|
|
@@ -790,8 +792,28 @@ ISR(TIMER2_OVF_vect) {
|
|
|
case 3:
|
|
|
PORTC = pc | Digit[3];
|
|
|
if (Digit[3] != DIGIT_BLANK) {
|
|
|
- if (Flag.blink3 == 0 || Flag.blinkC == 0) {
|
|
|
- PORTD = pd | ANOD4;
|
|
|
+ if (Flag.blink1 == 0 || Flag.blinkC == 0) {
|
|
|
+ PORTB = pb | ANOD4;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ idx = 4;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 4:
|
|
|
+ PORTC = pc | Digit[4];
|
|
|
+ if (Digit[4] != DIGIT_BLANK) {
|
|
|
+ if (Flag.blink2 == 0 || Flag.blinkC == 0) {
|
|
|
+ PORTB = pb | ANOD5;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ idx = 5;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 5:
|
|
|
+ PORTC = pc | Digit[5];
|
|
|
+ if (Digit[5] != DIGIT_BLANK) {
|
|
|
+ if (Flag.blink2 == 0 || Flag.blinkC == 0) {
|
|
|
+ PORTB = pb | ANOD6;
|
|
|
}
|
|
|
}
|
|
|
idx = 0;
|
|
@@ -811,7 +833,8 @@ ISR(TIMER2_OVF_vect) {
|
|
|
#pragma GCC optimize ("O3")
|
|
|
ISR(TIMER2_COMP_vect) {
|
|
|
// power off lamps
|
|
|
- PORTD &= ~ANOD_PINS;
|
|
|
+ PORTB &= ~ANODB_PINS;
|
|
|
+ PORTD &= ~ANODD_PINS;
|
|
|
PORTC &= ~DIGIT_PINS;
|
|
|
}
|
|
|
#endif // USE_BRIGHT_CONTROL
|