84 lines
1.1 KiB
C++
Raw Normal View History

2021-01-29 12:31:58 +01:00
//
// FILE: optoma.cpp
// AUTHOR: Rob Tillaart
2022-11-18 15:37:45 +01:00
// VERSION: 0.1.4
2021-01-29 12:31:58 +01:00
// DATE: 2017-11-27
2021-12-22 13:38:25 +01:00
// PUPROSE: Arduino library to control Optoma W305ST beamer over RS232.
2021-01-29 12:31:58 +01:00
// URL: https://github.com/RobTillaart/optoma
2021-12-22 13:38:25 +01:00
2021-01-29 12:31:58 +01:00
#include "optoma.h"
2021-12-22 13:38:25 +01:00
2021-01-29 12:31:58 +01:00
Optoma::Optoma(HardwareSerial* stream)
{
2022-11-18 15:37:45 +01:00
_stream = stream;
_ID = 0;
_on = false;
_baudrate = 9600;
2021-01-29 12:31:58 +01:00
}
2021-12-22 13:38:25 +01:00
2021-01-29 12:31:58 +01:00
void Optoma::init(int ID, uint32_t baudRate)
{
_ID = ID;
_stream->begin(baudRate);
_stream->print("# init : ");
_stream->print(baudRate);
_stream->print("\r");
}
2021-12-22 13:38:25 +01:00
2022-11-18 15:37:45 +01:00
uint32_t Optoma::getBaudrate()
{
return _baudrate;
};
2021-01-29 12:31:58 +01:00
void Optoma::switchOn()
{
sendID();
_stream->print(F("00 1\r"));
_on = true;
};
2021-12-22 13:38:25 +01:00
2021-01-29 12:31:58 +01:00
void Optoma::switchOff()
{
sendID();
_stream->print(F("00 0\r"));
_on = false;
};
2021-12-22 13:38:25 +01:00
2021-01-29 12:31:58 +01:00
void Optoma::increaseVKS()
{
sendID();
_stream->print(F("140 15\r"));
};
2021-12-22 13:38:25 +01:00
2021-01-29 12:31:58 +01:00
void Optoma::decreaseVKS()
{
sendID();
_stream->print(F("140 16\r"));
};
2021-12-22 13:38:25 +01:00
2021-01-29 12:31:58 +01:00
bool Optoma::isOn()
{
return _on;
};
2021-12-22 13:38:25 +01:00
2021-01-29 12:31:58 +01:00
void Optoma::sendID()
{
_stream->print('~');
if (_ID < 10) Serial.print('0');
_stream->print(_ID);
}
2021-12-22 13:38:25 +01:00
2022-11-18 15:37:45 +01:00
// -- END OF FILE --
2021-12-22 13:38:25 +01:00