Changed from dev mode to working mode. Lamp turns on after 24 frames. Will make it configurable.
This commit is contained in:
parent
39650094bd
commit
7981250d5a
|
@ -12,6 +12,7 @@ void ContactPrinter::Setup () {
|
||||||
pinMode(start_button_pin, INPUT_PULLUP);
|
pinMode(start_button_pin, INPUT_PULLUP);
|
||||||
|
|
||||||
drive_motor.Setup();
|
drive_motor.Setup();
|
||||||
|
lamp.Setup();
|
||||||
|
|
||||||
ledcSetup(takeup_pwm_channel, pwm_frequency, pwm_resolution);
|
ledcSetup(takeup_pwm_channel, pwm_frequency, pwm_resolution);
|
||||||
Serial.print("Attaching pin ");
|
Serial.print("Attaching pin ");
|
||||||
|
@ -40,6 +41,7 @@ void ContactPrinter::Start () {
|
||||||
|
|
||||||
void ContactPrinter::Stop () {
|
void ContactPrinter::Stop () {
|
||||||
Serial.println("Stop()");
|
Serial.println("Stop()");
|
||||||
|
lamp.Off();
|
||||||
drive_motor.Stop();
|
drive_motor.Stop();
|
||||||
StopTakeup();
|
StopTakeup();
|
||||||
run_time = timer;
|
run_time = timer;
|
||||||
|
@ -127,17 +129,19 @@ bool ContactPrinter::IsRunning () {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContactPrinter::Loop () {
|
void ContactPrinter::Loop () {
|
||||||
|
int32_t frame;
|
||||||
timer = millis();
|
timer = millis();
|
||||||
/*ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
|
|
||||||
pos = posi;
|
|
||||||
}*/
|
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
ButtonLoop();
|
ButtonLoop();
|
||||||
if (running) {
|
if (running) {
|
||||||
drive_motor.Loop();
|
drive_motor.Loop();
|
||||||
if (drive_motor.GetFrames() >= 1000) {
|
frame = drive_motor.GetFrames();
|
||||||
Stop();
|
if (!lamp.IsOn() && frame >= start_after) {
|
||||||
|
lamp.On();
|
||||||
}
|
}
|
||||||
|
/*if (frame >= 1000) {
|
||||||
|
Stop();
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
} else if (timer >= start_time + 100) {
|
} else if (timer >= start_time + 100) {
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
|
@ -53,6 +53,8 @@ class ContactPrinter {
|
||||||
|
|
||||||
volatile uint8_t load = 2; //0 = no load, 1 = single thread, 2 = dual thread
|
volatile uint8_t load = 2; //0 = no load, 1 = single thread, 2 = dual thread
|
||||||
|
|
||||||
|
volatile uint32_t start_after = 24;
|
||||||
|
|
||||||
volatile bool takeup_dir = true;
|
volatile bool takeup_dir = true;
|
||||||
volatile bool initialized = false;
|
volatile bool initialized = false;
|
||||||
volatile bool running = false;
|
volatile bool running = false;
|
||||||
|
|
|
@ -2,4 +2,25 @@
|
||||||
|
|
||||||
Lamp::Lamp () {
|
Lamp::Lamp () {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Lamp::Setup() {
|
||||||
|
pinMode(lamp_pin_a, OUTPUT);
|
||||||
|
digitalWrite(lamp_pin_a, LOW);
|
||||||
|
Serial.print("Simple white LED lamp on pin: ");
|
||||||
|
Serial.println(lamp_pin_a);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lamp::On () {
|
||||||
|
digitalWrite(lamp_pin_a, HIGH);
|
||||||
|
on = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lamp::Off () {
|
||||||
|
digitalWrite(lamp_pin_a, LOW);
|
||||||
|
on = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean Lamp::IsOn () {
|
||||||
|
return on;
|
||||||
|
}
|
|
@ -5,13 +5,17 @@
|
||||||
|
|
||||||
class Lamp {
|
class Lamp {
|
||||||
private:
|
private:
|
||||||
|
const uint8_t lamp_pin_a = 32;
|
||||||
volatile boolean on = false;
|
volatile boolean on = false;
|
||||||
volatile uint8_t lamp_pin_a = 33;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Lamp();
|
Lamp();
|
||||||
void Setup();
|
void Setup();
|
||||||
void Loop();
|
void Loop();
|
||||||
|
void On();
|
||||||
|
void Off();
|
||||||
|
boolean IsOn();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue