PS_Fgen_FW  4da88f4073c1cc65ea45c3a652a2751e495e50db
Firmware for an Power Supply and Function Generator build from an ATX power supply
Loading...
Searching...
No Matches
OnOffControls.h File Reference

Containing methods to handle on/off buttons. More...

#include "../Pins/Pins.h"

Go to the source code of this file.

Macros

#define ONOFFBUTTON_MCP23S08_PIN_PS   5
 Pin on the IO expander for the PS button.
 
#define ONOFFBUTTON_MCP23S08_PIN_DDS1   3
 Pin on the IO expander for the DDS1 button.
 
#define ONOFFBUTTON_MCP23S08_PIN_DDS2   1
 Pin on the IO expander for the DDS2 button.
 
#define ONOFFBUTTON_MCP23S08_PIN_MASK   ((1<<ONOFFBUTTON_MCP23S08_PIN_PS) | (1<<ONOFFBUTTON_MCP23S08_PIN_DDS1) | (1<<ONOFFBUTTON_MCP23S08_PIN_DDS2))
 Mask for all button pins on the IO expander.
 
#define ONOFFLED_MCP23S08_PIN_PS   4
 Pin on the IO expander for the PS LED.
 
#define ONOFFLED_MCP23S08_PIN_PS_ERROR   6
 Pin on the IO expander for the PS error LED.
 
#define ONOFFLED_MCP23S08_PIN_DDS1   2
 Pin on the IO expander for the DDS1 LED.
 
#define ONOFFLED_MCP23S08_PIN_DDS2   0
 Pin on the IO expander for the DDS2 LED.
 

Typedefs

typedef enum OnOffButtons OnOffButtons_t
 Enumeration with all available on/off buttons.
 
typedef enum OnOffLEDs OnOffLEDs_t
 Enumeration with all available on/off LEDs.
 

Enumerations

enum  OnOffButtons { ONOFFBUTTON_NONE , ONOFFBUTTON_PS , ONOFFBUTTON_DDS1 , ONOFFBUTTON_DDS2 }
 Enumeration with all available on/off buttons. More...
 
enum  OnOffLEDs { ONOFFLED_PS , ONOFFLED_PS_ERROR , ONOFFLED_DDS1 , ONOFFLED_DDS2 }
 Enumeration with all available on/off LEDs. More...
 

Functions

void OnOffControls_Init ()
 Initialize the IO expander used to access the on/off controls.
 
bool OnOffControls_IsButtonChanged ()
 Check if the state of any on/off button has changed (was pressed or was released).
 
OnOffButtons_t OnOffControls_GetButton ()
 Get the last pressed on/off button.
 
void OnOffControls_DoButtonAction (OnOffButtons_t button)
 Do some action depending on the pressed on/off button.
 
void OnOffControls_SetLEDState (OnOffLEDs_t led, bool state)
 Set the state of the on/off LED.
 
void OnOffControls_UpdatePSLeds ()
 Update the PS and PS error LEDs depending on the output enabled and protection states of the PS channel.
 

Detailed Description

Containing methods to handle on/off buttons.

Date
29.08.2024 18:39:00
Author
Markus Scheich

Enumeration Type Documentation

◆ OnOffButtons

Enumeration with all available on/off buttons.

Enumerator
ONOFFBUTTON_NONE 

no on/off button is pressed

ONOFFBUTTON_PS 

on/off button for the PS channel

ONOFFBUTTON_DDS1 

on/off button for the DDS1 channel

ONOFFBUTTON_DDS2 

on/off button for the DDS2 channel

◆ OnOffLEDs

enum OnOffLEDs

Enumeration with all available on/off LEDs.

Enumerator
ONOFFLED_PS 

on/off LED for the PS channel

ONOFFLED_PS_ERROR 

on/off LED for the PS channel error

ONOFFLED_DDS1 

on/off LED for the DDS1 channel

ONOFFLED_DDS2 

on/off LED for the DDS2 channel

Function Documentation

◆ OnOffControls_DoButtonAction()

void OnOffControls_DoButtonAction ( OnOffButtons_t button)

Do some action depending on the pressed on/off button.

Parameters
buttonon/off button that should be handled.

◆ OnOffControls_GetButton()

OnOffButtons_t OnOffControls_GetButton ( )

Get the last pressed on/off button.

Only one button is returned even if multiple buttons were pressed.

Returns
button that was pressed or ONOFFBUTTON_NONE if no button was pressed

◆ OnOffControls_IsButtonChanged()

bool OnOffControls_IsButtonChanged ( )

Check if the state of any on/off button has changed (was pressed or was released).

Returns
true, if any button state changed; otherwise false.

◆ OnOffControls_SetLEDState()

void OnOffControls_SetLEDState ( OnOffLEDs_t led,
bool state )

Set the state of the on/off LED.

Parameters
ledon/off LED that should be set.
statewhen true, the LED is turned on; if false, the LED is turned off

◆ OnOffControls_UpdatePSLeds()

void OnOffControls_UpdatePSLeds ( )

Update the PS and PS error LEDs depending on the output enabled and protection states of the PS channel.

Output Enabled Protection active LED PS LED PS error
false false off off
true false on off
false true off on
true true off on