Compare commits
No commits in common. "a88fae412e4b8528450d34647041b0c55112269c" and "691057a163b3d421f0951d35030e235c89a0a654" have entirely different histories.
a88fae412e
...
691057a163
4 changed files with 22 additions and 21 deletions
|
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
# Use the fancy version substitution
|
# Use the fancy version substitution
|
||||||
project(main
|
project(main
|
||||||
VERSION 0.1.2
|
VERSION 0.1.1
|
||||||
DESCRIPTION "template for cmake + cpputest"
|
DESCRIPTION "template for cmake + cpputest"
|
||||||
LANGUAGES C CXX
|
LANGUAGES C CXX
|
||||||
)
|
)
|
||||||
|
|
|
||||||
8
otto.sh
8
otto.sh
|
|
@ -180,7 +180,7 @@ cross_compile () {
|
||||||
|
|
||||||
build_release() {
|
build_release() {
|
||||||
clear_cmake_cache
|
clear_cmake_cache
|
||||||
cmake -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE} ../
|
cmake -DCAM_HANDLER_LIB=ON -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE} ../
|
||||||
make
|
make
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -197,7 +197,7 @@ build_hex () {
|
||||||
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${AVR_TC}"
|
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${AVR_TC}"
|
||||||
|
|
||||||
cmake ${CMAKE_ARGS} ../
|
cmake ${CMAKE_ARGS} ../
|
||||||
make main
|
make all
|
||||||
make hex
|
make hex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -208,7 +208,7 @@ build_hex_optimized () {
|
||||||
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${AVR_TC}"
|
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${AVR_TC}"
|
||||||
|
|
||||||
cmake ${CMAKE_ARGS} ../
|
cmake ${CMAKE_ARGS} ../
|
||||||
make main
|
make all
|
||||||
make hex-release
|
make hex-release
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -229,7 +229,7 @@ print_menu () {
|
||||||
echo "0. Add Mock Module"
|
echo "0. Add Mock Module"
|
||||||
echo "1. Run Tests"
|
echo "1. Run Tests"
|
||||||
echo "2. Build Project(hex)"
|
echo "2. Build Project(hex)"
|
||||||
echo "3. User Option"
|
echo "3. Build for release(hex)"
|
||||||
echo "4. Flash to AVR"
|
echo "4. Flash to AVR"
|
||||||
echo "5. Add new module to project"
|
echo "5. Add new module to project"
|
||||||
echo "6. Delete module from project"
|
echo "6. Delete module from project"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".elf")
|
||||||
if(NOT TARGET size)
|
if(NOT TARGET size)
|
||||||
# Set the size utility to display the size of the final binary
|
# Set the size utility to display the size of the final binary
|
||||||
add_custom_target(size ALL
|
add_custom_target(size ALL
|
||||||
COMMAND ${CMAKE_SIZE} -G --target=elf32-avr ${CMAKE_PROJECT_NAME}.elf
|
COMMAND ${CMAKE_SIZE} --format=avr --mcu=${AVR_MCU} ${CMAKE_PROJECT_NAME}.elf
|
||||||
DEPENDS ${CMAKE_PROJECT_NAME}.elf
|
DEPENDS ${CMAKE_PROJECT_NAME}.elf
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
27
src/main.c
27
src/main.c
|
|
@ -101,10 +101,10 @@ uint16_t ReadADC(void) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline uint8_t diff(uint8_t a, uint8_t b) {
|
static inline uint8_t diff(uint8_t a, uint8_t b) {
|
||||||
if (a > b) {
|
if(a > b){
|
||||||
return a - b;
|
return a - b;
|
||||||
}
|
}
|
||||||
return b - a;
|
return b - a;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MotorSetSavePos() {
|
void MotorSetSavePos() {
|
||||||
|
|
@ -119,7 +119,7 @@ uint8_t MotorGetSavedPos(void) {
|
||||||
|
|
||||||
void MotorMoveTo(uint8_t target) {
|
void MotorMoveTo(uint8_t target) {
|
||||||
|
|
||||||
uint8_t pos = (uint8_t)(ReadADC() >> 2);
|
uint8_t pos = (uint8_t)(ReadADC() >> 2);
|
||||||
|
|
||||||
while (diff(target, pos) > 8) {
|
while (diff(target, pos) > 8) {
|
||||||
pos = (uint8_t)(ReadADC() >> 2);
|
pos = (uint8_t)(ReadADC() >> 2);
|
||||||
|
|
@ -131,8 +131,8 @@ void MotorMoveTo(uint8_t target) {
|
||||||
|
|
||||||
// The delay ratio controlls the PWM waveforms.
|
// The delay ratio controlls the PWM waveforms.
|
||||||
//_delay_ms(5);
|
//_delay_ms(5);
|
||||||
// MotorCoast();
|
// MotorCoast();
|
||||||
// _delay_ms(5);
|
// _delay_ms(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
@ -212,7 +212,7 @@ static void UpdateButtonInput(btn_state *b) {
|
||||||
static void UpdateButtonOutput(btn_state *b) {
|
static void UpdateButtonOutput(btn_state *b) {
|
||||||
/*If the button is actually pressed.*/
|
/*If the button is actually pressed.*/
|
||||||
if (b->is_pressed) {
|
if (b->is_pressed) {
|
||||||
b->is_active = 1;
|
b->is_active = 1;
|
||||||
|
|
||||||
/*If this is a new event.*/
|
/*If this is a new event.*/
|
||||||
if (!b->is_long_pressed && !b->timer_enabled) {
|
if (!b->is_long_pressed && !b->timer_enabled) {
|
||||||
|
|
@ -242,11 +242,12 @@ static void UpdateButtonOutput(btn_state *b) {
|
||||||
}
|
}
|
||||||
/*If the button pres was a short one.*/
|
/*If the button pres was a short one.*/
|
||||||
else if (!b->is_long_pressed) {
|
else if (!b->is_long_pressed) {
|
||||||
if (b->is_active) {
|
if(b->is_active) {
|
||||||
MotorMoveTo(MotorGetSavedPos());
|
MotorMoveTo(MotorGetSavedPos());
|
||||||
} else {
|
}
|
||||||
MotorCoast();
|
else{
|
||||||
}
|
MotorCoast();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
b->is_active = 0;
|
b->is_active = 0;
|
||||||
ClearButtonTimer(b);
|
ClearButtonTimer(b);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue