Compare commits

...

2 Commits

Author SHA1 Message Date
radex 1233d07a1c
Stepper: Demo 2024-02-14 19:33:16 +01:00
radex 534d11741c
Memes: splash screen 2024-02-14 17:43:21 +01:00
10 changed files with 46 additions and 35 deletions

View File

@ -2,14 +2,6 @@
#include "constants.h"
#include <Arduino.h>
void helloBuzz() {
tone(BUZZER_PIN, 500, 100);
delay(100);
tone(BUZZER_PIN, 1000, 100);
delay(100);
tone(BUZZER_PIN, 4000, 100);
}
void happyBuzz() {
tone(BUZZER_PIN, 1500, 50);
delay(75);

View File

@ -1,6 +1,5 @@
#pragma once
void helloBuzz();
void happyBuzz();
void sadBuzz();
void beep();

View File

@ -30,6 +30,6 @@
// --- Z axis motor
#define STEPPER_ENABLE 8
#define STEPPER_DIR 9
#define STEPPER_STEP 10
#define STEPPER_ENABLE 10
#define STEPPER_DIR 8
#define STEPPER_STEP 9

View File

@ -9,6 +9,7 @@
#include "debug.h"
#include "timer.h"
#include "stepper.h"
#include "memes.h"
void setup() {
setupDebug();
@ -22,14 +23,12 @@ void setup() {
fatal();
}
helloBuzz();
splashScreen();
}
void loop() {
// debugScanI2C();
// demoScreen();
// demoStepper();
void loop() {
debugScanI2C();
demoTimer();
auto key = handleKeyboard();
@ -53,8 +52,6 @@ void loop() {
sadBuzz();
} else if (key == KEY_C) {
beep();
} else if (key == KEY_D) {
tick();
} else {
tick();
}
@ -68,5 +65,6 @@ void loop() {
if (auto event = handleEncoder()) {
tick();
Serial.println(event == ENCODER_CLOCKWISE ? "Clockwise" : "Counter-clockwise");
demoStepper(event == ENCODER_CLOCKWISE ? LOW : HIGH);
}
}

28
firmware/src/memes.cpp Normal file
View File

@ -0,0 +1,28 @@
#include <Arduino.h>
#include "screen.h"
#include "buzzer.h"
#include "constants.h"
void splashScreen() {
// lcd is slow, so we have to issue commands sufficiently early
// to synchronize with the hello buzz
lcd.clear();
lcd.print(" cewk");
delay(100);
tone(BUZZER_PIN, 500, 180);
delay(20);
lcd.print("-o-");
delay(100);
tone(BUZZER_PIN, 1000, 180);
delay(20);
lcd.print("mator");
delay(100);
tone(BUZZER_PIN, 4000, 180);
delay(500);
lcd.setCursor(0, 1);
lcd.print(" HSWAW 2024 ");
delay(300);
lcd.setCursor(0, 1);
lcd.print("by");
}

1
firmware/src/memes.h Normal file
View File

@ -0,0 +1 @@
void splashScreen();

View File

@ -17,8 +17,3 @@ bool setupScreen() {
lcd.clear();
return true;
}
void demoScreen() {
lcd.print(" cewk-o-mator ");
lcd.print(" HSWAW 2024 ");
}

View File

@ -1,6 +1,8 @@
#pragma once
#include <Arduino.h>
#include <LCD_I2C.h>
extern LCD_I2C lcd;
bool setupScreen();
void demoScreen();

View File

@ -10,16 +10,12 @@ void setupStepper() {
digitalWrite(STEPPER_ENABLE, LOW);
}
bool stepperDir = HIGH;
void demoStepper() {
Serial.println("Demoing stepper motor - rotating 200 steps");
stepperDir = !stepperDir;
digitalWrite(STEPPER_DIR, stepperDir);
for (int i = 0; i < 200; i++) {
void demoStepper(bool dir) {
digitalWrite(STEPPER_DIR, dir);
for (int i = 0; i < 3200; i++) {
digitalWrite(STEPPER_STEP, HIGH);
delay(2);
delayMicroseconds(25);
digitalWrite(STEPPER_STEP, LOW);
delay(7);
delayMicroseconds(25);
}
}

View File

@ -1,4 +1,4 @@
#pragma once
void setupStepper();
void demoStepper();
void demoStepper(bool dir);