improve readability

This commit is contained in:
Dennis Gunia
2025-09-11 22:02:37 +02:00
parent 1ace5dd9de
commit 405efd2906
7 changed files with 177 additions and 119 deletions

View File

@@ -0,0 +1,5 @@
---
CompileFlags:
Add:
- "-I/home/dennisgunia/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/avr/include/"
- "-I/home/dennisgunia/.config/VSCodium/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/19.1.2/clangd_19.1.2/lib/clang/19/include/stddef.h"

View File

@@ -0,0 +1,7 @@
9x16M gegenüber 6x12m. Höhe ca 3,0 - 3,5m
Bestuhlt oder unbestuhlt.
Derhstrom
Traversen.

View File

@@ -16,18 +16,18 @@
// I/O Pin definition
#define BUX_RX PD0
#define BUX_TX PD1
#define BUX_DIR PD2
#define SENSOR_HOME PD3
#define BUX_RX PD0 // RX Pin (to buffer)
#define BUX_TX PD1 // TX Pin (to buffer)
#define BUX_DIR PD2 // Buffer direction pin
#define SENSOR_HOME PD3 // Home sensor pin
#define MOTOR_A PC0
#define MOTOR_B PC1
#define MOTOR_C PC2
#define MOTOR_D PC3
#define MOTOR_A PC0 // Motor phase A driver
#define MOTOR_B PC1 // Motor phase B driver
#define MOTOR_C PC2 // Motor phase C driver
#define MOTOR_D PC3 // Motor phase D driver
// EEPROM Addresses
#define CONF_CONST_OKAY (uint8_t)0xAA
#define CONF_CONST_OKAY (uint8_t)0xAA
#define CONF_ADDR_OKAY 0x0004
#define CONF_ADDR_ADDR 0x0000
#define CONF_ADDR_OFFSET 0x0002
@@ -35,21 +35,21 @@
// Protocol definitions
#define PROTO_MAXPKGLEN 64 // maximum size of package in bytes
// Commands
#define CMDB_SETVAL (uint8_t)0x10
#define CMDB_SETVALR (uint8_t)0x11
#define CMDB_EEPROMR (uint8_t)0xF0
#define CMDB_EEPROMW (uint8_t)0xF1
#define CMDB_GSTS (uint8_t)0xF8
#define CMDB_PING (uint8_t)0xFE
#define CMDB_RESET (uint8_t)0x30
#define CMDB_PWRON (uint8_t)0x21
#define CMDB_RPWROFF (uint8_t)0x20
// Command Bytes
#define CMDB_SETVAL (uint8_t)0x10 // Set display value
#define CMDB_SETVALR (uint8_t)0x11 // Set display value and do a full rotation
#define CMDB_EEPROMR (uint8_t)0xF0 // Read EEPROM
#define CMDB_EEPROMW (uint8_t)0xF1 // Write EEPROM
#define CMDB_GSTS (uint8_t)0xF8 // Get status
#define CMDB_PING (uint8_t)0xFE // Ping
#define CMDB_RESET (uint8_t)0x30 // Reset device
#define CMDB_PWRON (uint8_t)0x21 // Power motor on
#define CMDB_RPWROFF (uint8_t)0x20 // Poer motor off
// Reply
#define CMDR_ERR_INVALID 0xEE
#define CMDR_ACK 0xAA
#define CMDR_PING 0xFF
// Command Responses
#define CMDR_ERR_INVALID 0xEE // Invalid command
#define CMDR_ACK 0xAA // Acknowledge
#define CMDR_PING 0xFF // Ping response
// Utility definitions
#define SHIFT_0B 0

View File

@@ -17,7 +17,7 @@ uint8_t motor_steps[4] = {
0b00001000,
};
uint8_t step_index = 0; // cuurent index in motor_steps
uint8_t step_index = 0; // current index in motor_steps
uint8_t target_flap = 0; // target flap
uint16_t absolute_pos = 0; // absolute position in steps
uint16_t steps_since_home = 0; // steps since last home signal
@@ -29,7 +29,7 @@ uint8_t lastSens = 0; // home sonsor signal from last tick
// counter for auto powersaving
uint8_t ticksSinceMove = 0;
// value to goto after the current target_flap is reached. 255 = NONE.
// value to goto after the current is reached. 255 = NONE.
uint8_t afterRotation = STEPS_AFTERROT;
int16_t *delta_err;
@@ -58,7 +58,7 @@ void mctrl_init()
// setup adc
ADMUX = 0x07; // Aref, ADC7
ADCSRA = (1 << ADEN) | (1 << ADSC) | (1 << ADPS1); // Enable ADC, Start first
// reading No frerunning, 8MHz
// reading No freerunning, 8MHz
while ((ADCSRA & (1 << ADSC)) > 0)
{
};
@@ -188,7 +188,7 @@ ISR(TIMER1_COMPA_vect)
}
else
{ // if target position is reached
if (afterRotation < (STEPS_PER_FLAP + 5))
if (afterRotation < (AMOUNTFLAPS + 5))
{ // if after rotation is set, apply it as new target
target_flap = afterRotation;
afterRotation = STEPS_AFTERROT;

View File

@@ -9,13 +9,11 @@
#pragma once
//#define F_CPU 16000000UL
#define UART_BAUD 19200
#define UART_BAUD 19200 // RS485 baud rate
#define BAUDRATE ((F_CPU) / (UART_BAUD * 16UL) - 1) // set baud rate value for UBRR
#define SFBUS_SOF_BYTE '+'
#define SFBUS_EOF_BYTE '$'
#define SFBUS_SOF_BYTE '+' // Byte marks start of frame
#define SFBUS_EOF_BYTE '$' // Byte marks end of frame
#ifdef __cplusplus
extern "C" {