commented out code that won't be used for hardware tests.

This commit is contained in:
Jake Goodwin 2025-02-12 14:53:26 -08:00
parent 98c9fde2b9
commit e50463ab2b
1 changed files with 35 additions and 36 deletions

View File

@ -1,7 +1,3 @@
#ifndef MCU
#define MCU atiny13a
#endif
#ifndef F_CPU
#define F_CPU 4800000UL
#endif
@ -12,7 +8,7 @@
#include <util/delay.h>
// These are only included during development for the LSP server.
#include "iotn13.h"
//#include "iotn13.h"
// #include "iotn13a.h"
// #############################
@ -37,7 +33,6 @@ volatile uint16_t tick_count;
static inline void InitTimer0(void);
static void InitBtn(btn_state *b, uint8_t input_pin, uint8_t output_pin);
static void ToggleOutput(btn_state *b);
static void ClearButtonTimer(btn_state *b);
static void StartButtonTimer(btn_state *b);
static void CheckButtonLongpress(btn_state *b);
@ -48,7 +43,7 @@ static void UpdateButtonOutput(btn_state *b);
// MAIN
// #############################
int main(int argc, char **argv) {
int main() {
InitProg();
while (1) {
@ -106,27 +101,42 @@ uint16_t ReadADC(void) {
* ############################
*/
void MotorSetSavePos()
{
void MotorSetSavePos() {
uint8_t pos = (uint8_t)(ReadADC() >> 2);
eeprom_write_byte((uint8_t *)ROM_SS1_ADR, pos);
return;
}
uint8_t MotorGetSavedPos(void)
{
uint8_t MotorGetSavedPos(void) {
return (uint8_t)eeprom_read_byte((uint8_t *)ROM_SS1_ADR);
}
void MotorMoveTo(uint8_t pos)
{
void MotorMoveTo(uint8_t target) {
uint8_t pos = 0;
while (target != pos) {
pos = (uint8_t)(ReadADC() >> 2);
if (target > pos) {
MotorMove(1);
} else {
MotorMove(0);
}
// The delay ratio controlls the PWM waveforms.
_delay_ms(50);
MotorCoast();
_delay_ms(50);
}
return;
}
// Using the compatable bool type.
void MotorMove(uint8_t fwd)
{
void MotorMove(uint8_t fwd) {
if (fwd) {
PORTB |= (1 << PWM_PIN1);
PORTB &= ~(1 << PWM_PIN2);
} else {
PORTB |= (1 << PWM_PIN2);
PORTB &= ~(1 << PWM_PIN1);
}
return;
}
@ -158,17 +168,6 @@ static void InitBtn(btn_state *b, uint8_t input_pin, uint8_t output_pin) {
PORTB &= ~(1 << b->output_pin);
}
/*This is the fancy function to toggle output pins*/
static void ToggleOutput(btn_state *b) {
if (!b->is_active) {
b->is_active = 1;
PORTB |= (1 << b->output_pin);
} else {
b->is_active = 0;
PORTB &= ~(1 << b->output_pin);
}
}
static void ClearButtonTimer(btn_state *b) {
b->timer_enabled = 0;
b->is_long_pressed = 0;