This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
Distancer/LcdShiftReg.cpp

46 lines
675 B
C++
Raw Permalink Normal View History

#include "LcdShiftReg.h"
#include <avr/io.h>
LcdShiftReg::LcdShiftReg()
{
DDRA |= (1 << PA0) | (1 << PA1) | (1 << PA2);
}
2017-03-02 07:18:07 +00:00
void LcdShiftReg::setPin(volatile uint8_t *port, uint8_t pin) const
{
*port |= (1 << pin);
}
void LcdShiftReg::clearPin(volatile uint8_t *port, uint8_t pin) const
{
*port &= ~(1 << pin);
}
void LcdShiftReg::setSerialPin(bool value)
{
if (value == true)
{
2017-03-02 07:18:07 +00:00
setPin(&PORTA, PA2);
}
else
{
2017-03-02 07:18:07 +00:00
clearPin(&PORTA, PA2);
}
}
2017-03-02 07:18:07 +00:00
void LcdShiftReg::pulseShiftPin()
{
2017-03-02 07:18:07 +00:00
clearPin(&PORTA, PA0);
setPin(&PORTA, PA0);
clearPin(&PORTA, PA0);
}
2017-03-02 07:18:07 +00:00
void LcdShiftReg::pulseStoragePin()
{
2017-03-02 07:18:07 +00:00
clearPin(&PORTA, PA1);
setPin(&PORTA, PA1);
clearPin(&PORTA, PA1);
}