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