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);
|
||||
|
||||
drive_motor.Setup();
|
||||
lamp.Setup();
|
||||
|
||||
ledcSetup(takeup_pwm_channel, pwm_frequency, pwm_resolution);
|
||||
Serial.print("Attaching pin ");
|
||||
|
@ -40,6 +41,7 @@ void ContactPrinter::Start () {
|
|||
|
||||
void ContactPrinter::Stop () {
|
||||
Serial.println("Stop()");
|
||||
lamp.Off();
|
||||
drive_motor.Stop();
|
||||
StopTakeup();
|
||||
run_time = timer;
|
||||
|
@ -127,17 +129,19 @@ bool ContactPrinter::IsRunning () {
|
|||
}
|
||||
|
||||
void ContactPrinter::Loop () {
|
||||
int32_t frame;
|
||||
timer = millis();
|
||||
/*ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
|
||||
pos = posi;
|
||||
}*/
|
||||
if (initialized) {
|
||||
ButtonLoop();
|
||||
if (running) {
|
||||
drive_motor.Loop();
|
||||
if (drive_motor.GetFrames() >= 1000) {
|
||||
Stop();
|
||||
frame = drive_motor.GetFrames();
|
||||
if (!lamp.IsOn() && frame >= start_after) {
|
||||
lamp.On();
|
||||
}
|
||||
/*if (frame >= 1000) {
|
||||
Stop();
|
||||
}*/
|
||||
}
|
||||
} else if (timer >= start_time + 100) {
|
||||
initialized = true;
|
||||
|
|
|
@ -53,6 +53,8 @@ class ContactPrinter {
|
|||
|
||||
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 initialized = false;
|
||||
volatile bool running = false;
|
||||
|
|
|
@ -2,4 +2,25 @@
|
|||
|
||||
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 {
|
||||
private:
|
||||
const uint8_t lamp_pin_a = 32;
|
||||
volatile boolean on = false;
|
||||
volatile uint8_t lamp_pin_a = 33;
|
||||
|
||||
public:
|
||||
Lamp();
|
||||
void Setup();
|
||||
void Loop();
|
||||
void On();
|
||||
void Off();
|
||||
boolean IsOn();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue