moved the threshold values into load.h as defines.

This commit is contained in:
jakeg00dwin 2024-07-02 15:43:49 -07:00
parent fa1dd00965
commit e4f19012b0
4 changed files with 19 additions and 41 deletions

View File

@ -14,31 +14,7 @@
#ifndef CONFIG_H
#define CONFIG_H
//#define __AVR_ATtiny404__
#include <stdint.h>
//#include <avr/io.h>
//#define ZC_PORT_DIR &PORTA.DIR
//*ZCP_DIR = &PORTA.DIR;
/**
* @brief Result type for the returned values from functions
*
*/
typedef enum ResultEnum{
OK,
Err
}ResultEnum;
/**
* @brief The type for Triac gate duration(micro seconds)
*
*/
typedef uint16_t DurationUs_t;
/**
@ -71,18 +47,6 @@ const int GatePulsesQty = 5;
*/
const uint16_t GatePulses[5] = {250, 500, 750, 1000, 1250};
/**
* @brief Low Threshold
*
*/
const uint16_t LowThresh = 527;
/**
* @brief High Threshold
*
*/
const uint16_t HighThresh = 1000;
/**
* @brief The time constant.
*/

9
load.c
View File

@ -1,8 +1,9 @@
#include <avr/io.h>
#include "load.h"
#include "ADC.h"
#include "config.h"
#include "RegEdit.h"
#define ADC_LOAD1 4
#define ADC_LOAD2 5
#define ADC_LOAD3 6
@ -49,13 +50,13 @@ void Load_HandlePinLoads(void)
RegEdit_SetNum((void *) &PORTA.OUT, porta_out_state);
RegEdit_SetNum((void *) &PORTB.OUT, portb_out_state);
if(load_one < LowThresh || load_one > HighThresh){
if(load_one < LOWTHRESH || load_one > HIGHTHRESH){
RegEdit_ClearBit((void *) &PORTA.OUT, G1);
}
if(load_two < LowThresh || load_two > HighThresh){
if(load_two < LOWTHRESH || load_two > HIGHTHRESH){
RegEdit_ClearBit((void *) &PORTB.OUT, G2);
}
if(load_three < LowThresh || load_three > HighThresh){
if(load_three < LOWTHRESH || load_three > HIGHTHRESH){
RegEdit_ClearBit((void *) &PORTB.OUT, G3);
}

13
load.h
View File

@ -10,6 +10,19 @@
#ifndef LOAD_H
#define LOAD_H
/**
* @brief Low Threshold
*
*/
#define LOWTHRESH 527
/**
* @brief High Threshold
*
*/
#define HIGHTHRESH 1000
void Load_HandlePinLoads(void);

2
main.c
View File

@ -51,7 +51,7 @@ int main(int argc, char **argv)
ZCD_Poll();
TriacOut_SetupPins();
TriacOut_SetAllHigh();
Load_HandlePinLoads(void);
Load_HandlePinLoads();
while(true){
; //Do nothing until new Power cycle/reset occurs
}