GY-63_MS5611/libraries/Par27979/Par27979.h

76 lines
1.7 KiB
C
Raw Normal View History

2020-11-27 05:28:57 -05:00
#pragma once
//
// FILE: PAR27979.h
// AUTHOR: Rob Tillaart
2022-11-19 08:49:48 -05:00
// VERSION: 0.2.4
2020-11-27 05:28:57 -05:00
// PURPOSE: Arduino library for Parallax 27979 _serial LCD display
// URL: https://github.com/RobTillaart/PAR27979
2021-01-29 06:31:58 -05:00
2022-11-19 08:49:48 -05:00
#define PAR27929_LIB_VERSION (F("0.2.4"))
2013-09-30 12:12:19 -04:00
2020-11-27 05:28:57 -05:00
#include "Arduino.h"
2021-11-11 06:31:09 -05:00
2020-11-27 05:28:57 -05:00
class PAR27979 : public Print
2013-09-30 12:12:19 -04:00
{
2020-11-27 05:28:57 -05:00
public:
PAR27979(Stream * str) { _ser = str; };
void on() { _ser->write(22); };
void off() { _ser->write(21); };
void clearHome() { _ser->write(12); delay(5); };
void backlightOn() { _ser->write(17); };
void backlightOff() { _ser->write(18); };
2022-11-19 08:49:48 -05:00
// MOVEMENT
2020-11-27 05:28:57 -05:00
void left() { _ser->write(8); };
void right() { _ser->write(9); };
void down() { _ser->write(10); };
void gotoXY(uint8_t x, uint8_t y) { _ser->write(128 + y*20 + x); };
2022-11-19 08:49:48 -05:00
// CUSTOM CHARS
// array will need to be 8 bytes. - see datasheet.
2020-11-27 05:28:57 -05:00
void defineCustomChar(uint8_t idx, uint8_t * arr)
{
_ser->write(248 + idx);
for (int i = 0; i < 8; i++) _ser->write(arr[i]);
}
void customChar(uint8_t idx) { _ser->write(idx); };
2022-11-19 08:49:48 -05:00
// PLAY MUSIC
// octave = 3, 4, 5, 6, 7
2020-11-27 05:28:57 -05:00
void octave(uint8_t octave) { _ser->write(212 + octave); };
2022-11-19 08:49:48 -05:00
// duration is in 1/64 = 1, 2, 4, 8, 16, 32, 64
2020-11-27 05:28:57 -05:00
void duration(uint8_t duration)
{
uint8_t ch = 207;
while(duration) { duration /= 2; ch++; };
_ser->write(ch);
}
2022-11-19 08:49:48 -05:00
// A = 0, A# = 1 etc, see datasheet
2020-11-27 05:28:57 -05:00
void play(uint8_t note) { _ser->write(220 + note); };
void noSound() { _ser->write(232); };
2022-11-19 08:49:48 -05:00
// PRINT interface
2020-11-27 05:28:57 -05:00
size_t write(const uint8_t data) { return _ser->write(data); };
2021-12-22 08:08:07 -05:00
size_t write(const uint8_t * data, uint8_t length)
2021-11-11 06:31:09 -05:00
{
2021-12-22 08:08:07 -05:00
return _ser->write(data, length);
2021-11-11 06:31:09 -05:00
};
2020-11-27 05:28:57 -05:00
private:
Stream *_ser;
};
2021-12-22 08:08:07 -05:00
2022-11-19 08:49:48 -05:00
// -- END OF FILE --
2021-12-22 08:08:07 -05:00