second edition nearly working
This commit is contained in:
parent
8ad6c780f7
commit
63d3d29852
@ -7,6 +7,8 @@ P2.2 G
|
|||||||
P2.1 C
|
P2.1 C
|
||||||
P2.0 1
|
P2.0 1
|
||||||
P1.5 2
|
P1.5 2
|
||||||
|
P1.2 3
|
||||||
|
P1.1 LED
|
||||||
P1.0 T
|
P1.0 T
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,15 +47,15 @@ const tPin *NUMBERS[] = { NUMBER0, NUMBER1, NUMBER2, NUMBER3, NUMBER4,
|
|||||||
NUMBER5, NUMBER6, NUMBER7, NUMBER8, NUMBER9, ALL_PATTERN, H_PATTERN,
|
NUMBER5, NUMBER6, NUMBER7, NUMBER8, NUMBER9, ALL_PATTERN, H_PATTERN,
|
||||||
I_PATTERN, EMPTY_PATTERN };
|
I_PATTERN, EMPTY_PATTERN };
|
||||||
|
|
||||||
const tPin DIGITS[] = { DIGIT_0, DIGIT_1, PINS_END };
|
const tPin DIGITS[] = { DIGIT_0, DIGIT_1, DIGIT_2, PINS_END };
|
||||||
|
|
||||||
|
|
||||||
uint8_t digitValues[2] = { EMPTY_ID, EMPTY_ID };
|
uint8_t digitValues[] = { EMPTY_ID, EMPTY_ID, EMPTY_ID };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void displayInit(void *handleArg) {
|
void displayInit(void *handleArg) {
|
||||||
for (tPin d = DIGIT_0; d <= DIGIT_1; d++) {
|
for (tPin d = DIGIT_0; d <= DIGIT_2; d++) {
|
||||||
gpioSetPin(d, LOW);
|
gpioSetPin(d, LOW);
|
||||||
for (tPin s = SEG_A; s <= SEG_G; s++) {
|
for (tPin s = SEG_A; s <= SEG_G; s++) {
|
||||||
gpioSetPin(s, HIGH);
|
gpioSetPin(s, HIGH);
|
||||||
@ -80,20 +80,23 @@ static void showNumber(uint8_t n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void displaySetValue(uint8_t v) {
|
void displaySetValue(uint8_t v) {
|
||||||
if (v >= 100) {
|
uint32_t a,b,c,d;
|
||||||
digitValues[1] = H_ID;
|
a = v;
|
||||||
digitValues[0] = I_ID;
|
b = a / 100;
|
||||||
} else {
|
c = (a - b * 100) / 10;
|
||||||
digitValues[1] = v / 10;
|
d = a - c * 10 - b * 100;
|
||||||
digitValues[0] = v - digitValues[1] * 10;
|
b = (b == 0) ? EMPTY_ID : b;
|
||||||
}
|
c = (c == 0) ? EMPTY_ID : c;
|
||||||
|
digitValues[2] = (uint8_t)b;
|
||||||
|
digitValues[1] = (uint8_t)c;
|
||||||
|
digitValues[0] = (uint8_t)d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayExec(void *handleArg) {
|
void displayExec(void *handleArg) {
|
||||||
static uint8_t activeDigit = 0;
|
static uint8_t activeDigit = 0;
|
||||||
|
|
||||||
activeDigit++;
|
activeDigit++;
|
||||||
if (activeDigit == 2) {
|
if (activeDigit == 3) {
|
||||||
activeDigit = 0;
|
activeDigit = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,11 +16,12 @@
|
|||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
#include "PontCoopScheduler.h"
|
#include "PontCoopScheduler.h"
|
||||||
|
#include "powerDown.h"
|
||||||
|
|
||||||
|
|
||||||
const uint32_t EGG_TIMER_CYCLE = 1000;
|
const uint32_t EGG_TIMER_CYCLE = 1000;
|
||||||
const uint32_t LED_CYCLE = 250;
|
const uint32_t LED_CYCLE = 250;
|
||||||
const uint32_t POWER_DOWN_DELAY = 120000;
|
const uint32_t MY_POWER_DOWN_DELAY = 120000;
|
||||||
|
|
||||||
const uint8_t COOKING_TIME = 120;
|
const uint8_t COOKING_TIME = 120;
|
||||||
uint8_t restCookingTime;
|
uint8_t restCookingTime;
|
||||||
@ -28,14 +29,8 @@ bool timerRunning;
|
|||||||
bool timerStarted;
|
bool timerStarted;
|
||||||
|
|
||||||
|
|
||||||
void eggTimerPowerDown(void *handleArg) {
|
|
||||||
P1DIR = 0;
|
|
||||||
P2DIR = 0;
|
|
||||||
P1OUT = 0;
|
|
||||||
P2OUT = 0;
|
|
||||||
ADC10CTL0 = 0;
|
|
||||||
LPM4;
|
|
||||||
}
|
|
||||||
|
|
||||||
void eggTimerStart(void *handleArg) {
|
void eggTimerStart(void *handleArg) {
|
||||||
if (! timerStarted) {
|
if (! timerStarted) {
|
||||||
@ -62,7 +57,8 @@ void eggTimerExec(void *handleArg) {
|
|||||||
if (restCookingTime == 0) {
|
if (restCookingTime == 0) {
|
||||||
// activate alarm
|
// activate alarm
|
||||||
schAdd(eggTimerAlarm, NULL, 0, LED_CYCLE);
|
schAdd(eggTimerAlarm, NULL, 0, LED_CYCLE);
|
||||||
schAdd(eggTimerPowerDown, NULL, POWER_DOWN_DELAY, 0);
|
schDel(powerDown, NULL);
|
||||||
|
schAdd(powerDown, NULL, MY_POWER_DOWN_DELAY, 0);
|
||||||
timerRunning = false;
|
timerRunning = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,9 +49,9 @@ typedef enum {
|
|||||||
SEG_G,
|
SEG_G,
|
||||||
DIGIT_0,
|
DIGIT_0,
|
||||||
DIGIT_1,
|
DIGIT_1,
|
||||||
|
DIGIT_2,
|
||||||
BUTTON_1,
|
BUTTON_1,
|
||||||
LED_1,
|
LED_1,
|
||||||
POWER,
|
|
||||||
PINS_END
|
PINS_END
|
||||||
} tPin;
|
} tPin;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ tPinCfg pinCfg[PINS_END] = {
|
|||||||
{PORT2, BIT2, PIN_OUT, LOW}, //G
|
{PORT2, BIT2, PIN_OUT, LOW}, //G
|
||||||
{PORT2, BIT0, PIN_OUT, HIGH}, //0
|
{PORT2, BIT0, PIN_OUT, HIGH}, //0
|
||||||
{PORT1, BIT5, PIN_OUT, HIGH}, //1
|
{PORT1, BIT5, PIN_OUT, HIGH}, //1
|
||||||
|
{PORT1, BIT2, PIN_OUT, HIGH}, //2
|
||||||
{PORT1, BIT0, PIN_IN_PULLUP, LOW}, // BUTTON_1
|
{PORT1, BIT0, PIN_IN_PULLUP, LOW}, // BUTTON_1
|
||||||
{PORT1, BIT1, PIN_OUT, LOW}, // LED_1
|
{PORT1, BIT1, PIN_OUT, LOW}, // LED_1
|
||||||
{PORT1, BIT2, PIN_OUT, HIGH}, // POWER
|
|
||||||
};
|
};
|
||||||
|
32
src/main.c
32
src/main.c
@ -20,21 +20,10 @@
|
|||||||
#include "eggTimer.h"
|
#include "eggTimer.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
|
#include "powerDown.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void powerDown(void *handleArg) {
|
|
||||||
P1OUT = 0;
|
|
||||||
P1DIR = 0xff;
|
|
||||||
P1REN = 0;
|
|
||||||
P2OUT = 0;
|
|
||||||
P2DIR = 0xff;
|
|
||||||
P2REN = 0;
|
|
||||||
ADC10CTL0 = 0;
|
|
||||||
|
|
||||||
LPM4;
|
|
||||||
while (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
WDTCTL = WDTPW | WDTHOLD;
|
WDTCTL = WDTPW | WDTHOLD;
|
||||||
@ -50,18 +39,8 @@ int main() {
|
|||||||
timeInit();
|
timeInit();
|
||||||
schInit();
|
schInit();
|
||||||
|
|
||||||
|
schAdd(powerDown, NULL, 600000, 0);
|
||||||
|
|
||||||
schAdd(eggTimerAlarm, NULL, 0, 37);
|
|
||||||
schAdd(powerDown, NULL, 5000, 0);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
// interrupts are required for delay function in displayInit();
|
// interrupts are required for delay function in displayInit();
|
||||||
__enable_interrupt();
|
__enable_interrupt();
|
||||||
displayInit(NULL);
|
displayInit(NULL);
|
||||||
@ -78,17 +57,12 @@ int main() {
|
|||||||
schAdd(eggTimerExec, NULL, 0, EGG_TIMER_CYCLE);
|
schAdd(eggTimerExec, NULL, 0, EGG_TIMER_CYCLE);
|
||||||
schAdd(buttonExec, NULL, 0, BUTTON_CYCLE);
|
schAdd(buttonExec, NULL, 0, BUTTON_CYCLE);
|
||||||
|
|
||||||
#endif
|
|
||||||
__enable_interrupt();
|
__enable_interrupt();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
schExec();
|
schExec();
|
||||||
LPM3;
|
LPM3;
|
||||||
|
|
||||||
// put it into the idle loop, it is not time critical
|
|
||||||
// but should get as much time as possible to avoid
|
|
||||||
// flicker
|
|
||||||
//displayExec(NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
23
src/powerDown.c
Normal file
23
src/powerDown.c
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* powerDown.c
|
||||||
|
*
|
||||||
|
* Created on: Sep 11, 2016
|
||||||
|
* Author: wn
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <msp430g2553.h>
|
||||||
|
|
||||||
|
|
||||||
|
void powerDown(void *handleArg) {
|
||||||
|
P1OUT = 0;
|
||||||
|
P1DIR = 0xff;
|
||||||
|
P1REN = 0;
|
||||||
|
P2OUT = 0;
|
||||||
|
P2DIR = 0xff;
|
||||||
|
P2REN = 0;
|
||||||
|
ADC10CTL0 = 0;
|
||||||
|
|
||||||
|
LPM4;
|
||||||
|
while (1);
|
||||||
|
}
|
14
src/powerDown.h
Normal file
14
src/powerDown.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* powerDown.h
|
||||||
|
*
|
||||||
|
* Created on: Sep 11, 2016
|
||||||
|
* Author: wn
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef POWERDOWN_H_
|
||||||
|
#define POWERDOWN_H_
|
||||||
|
|
||||||
|
void powerDown(void *handleArg);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* POWERDOWN_H_ */
|
Loading…
x
Reference in New Issue
Block a user