Compare commits
No commits in common. 'bc3e7cc7e46ed9fc4fe3691ddbffe29fb14bae93' and '18f87495948812193a9d5c6d74714a30f55c73e6' have entirely different histories.
bc3e7cc7e4
...
18f8749594
File diff suppressed because it is too large
Load Diff
@ -1,15 +0,0 @@ |
|||||||
#ifndef MONOFORMAT_PARSEONLY_HPP |
|
||||||
#define MONOFORMAT_PARSEONLY_HPP |
|
||||||
|
|
||||||
#include "monoformat_parsehelpers.hpp" |
|
||||||
#include "monoformat_schema.hpp" |
|
||||||
|
|
||||||
namespace monoformat { |
|
||||||
|
|
||||||
std::expected<void, ParseError> parseAndApply(std::span<std::byte const> data, OneBitBufferInterface* buffer, |
|
||||||
std::uint16_t screenWidth, std::uint16_t screenHeight, |
|
||||||
bool isFront, std::size_t animationTick, std::int64_t currentTimestamp); |
|
||||||
|
|
||||||
} // namespace monoformat
|
|
||||||
|
|
||||||
#endif // MONOFORMAT_PARSEONLY_HPP
|
|
||||||
@ -1,103 +0,0 @@ |
|||||||
#include "monoformat_schema.hpp" |
|
||||||
|
|
||||||
#include <tuple> |
|
||||||
|
|
||||||
namespace monoformat { |
|
||||||
|
|
||||||
MemoryOneBitBuffer::MemoryOneBitBuffer(std::span<std::byte> buffer, std::uint16_t width, std::uint16_t height) |
|
||||||
: m_width{width} |
|
||||||
, m_height{height} |
|
||||||
, m_buffer{buffer} |
|
||||||
{ |
|
||||||
std::size_t expectedSize = (m_width * m_height + 8 - 1) / 8; |
|
||||||
if (m_buffer.size() < expectedSize) { |
|
||||||
m_width = 0; |
|
||||||
m_height = 0; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
MemoryOneBitBuffer::~MemoryOneBitBuffer() { |
|
||||||
} |
|
||||||
|
|
||||||
bool MemoryOneBitBuffer::isPixelSet(std::uint16_t x, std::uint16_t y) const { |
|
||||||
if (x >= m_width || y >= m_height) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
std::size_t pxIndex = static_cast<std::size_t>(y) * m_width + x; |
|
||||||
std::size_t byteIndex = pxIndex / 8; |
|
||||||
std::size_t bitIndex = pxIndex % 8; |
|
||||||
return ((static_cast<std::uint8_t>(m_buffer[byteIndex]) >> bitIndex) & 0x01) == 0x01; |
|
||||||
} |
|
||||||
|
|
||||||
void MemoryOneBitBuffer::setPixel(std::uint16_t x, std::uint16_t y, bool value) { |
|
||||||
if (x >= m_width || y >= m_height) { |
|
||||||
return; |
|
||||||
} |
|
||||||
std::size_t pxIndex = static_cast<std::size_t>(y) * m_width + x; |
|
||||||
std::size_t byteIndex = pxIndex / 8; |
|
||||||
std::size_t bitIndex = pxIndex % 8; |
|
||||||
if (value) { |
|
||||||
m_buffer[byteIndex] = static_cast<std::byte>(static_cast<std::uint8_t>(m_buffer[byteIndex]) | (1u << bitIndex)); |
|
||||||
} else { |
|
||||||
m_buffer[byteIndex] = static_cast<std::byte>(static_cast<std::uint8_t>(m_buffer[byteIndex]) & ~(1u << bitIndex)); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
ConstMemoryOneBitBuffer::ConstMemoryOneBitBuffer(std::span<std::byte const> buffer, std::uint16_t width, std::uint16_t height) |
|
||||||
: m_width{width} |
|
||||||
, m_height{height} |
|
||||||
, m_buffer{buffer} |
|
||||||
{ |
|
||||||
std::size_t expectedSize = (m_width * m_height + 8 - 1) / 8; |
|
||||||
if (m_buffer.size() < expectedSize) { |
|
||||||
m_width = 0; |
|
||||||
m_height = 0; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
ConstMemoryOneBitBuffer::~ConstMemoryOneBitBuffer() { |
|
||||||
} |
|
||||||
|
|
||||||
bool ConstMemoryOneBitBuffer::isPixelSet(std::uint16_t x, std::uint16_t y) const { |
|
||||||
if (x >= m_width || y >= m_height) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
std::size_t pxIndex = static_cast<std::size_t>(y) * m_width + x; |
|
||||||
std::size_t byteIndex = pxIndex / 8; |
|
||||||
std::size_t bitIndex = pxIndex % 8; |
|
||||||
return ((static_cast<std::uint8_t>(m_buffer[byteIndex]) >> bitIndex) & 0x01) == 0x01; |
|
||||||
} |
|
||||||
|
|
||||||
void ConstMemoryOneBitBuffer::setPixel(std::uint16_t x, std::uint16_t y, bool value) { |
|
||||||
std::ignore = x; |
|
||||||
std::ignore = y; |
|
||||||
std::ignore = value; |
|
||||||
} |
|
||||||
|
|
||||||
ClippedImage::ClippedImage(OneBitBufferInterface* underlying, std::uint16_t x, std::uint16_t y, std::uint16_t width, std::uint16_t height) |
|
||||||
: m_underlying{underlying} |
|
||||||
, m_x{x} |
|
||||||
, m_y{y} |
|
||||||
, m_width{width} |
|
||||||
, m_height{height} |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
ClippedImage::~ClippedImage() { |
|
||||||
} |
|
||||||
|
|
||||||
bool ClippedImage::isPixelSet(std::uint16_t x, std::uint16_t y) const { |
|
||||||
if (x >= m_width || y >= m_height) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
return m_underlying->isPixelSet(x + m_x, y + m_y); |
|
||||||
} |
|
||||||
|
|
||||||
void ClippedImage::setPixel(std::uint16_t x, std::uint16_t y, bool value) { |
|
||||||
if (x >= m_width || y >= m_height) { |
|
||||||
return; |
|
||||||
} |
|
||||||
m_underlying->setPixel(x + m_x, y + m_y, value); |
|
||||||
} |
|
||||||
|
|
||||||
} // namespace monoformat
|
|
||||||
@ -1,77 +0,0 @@ |
|||||||
#ifndef MONOFORMAT_SCHEMA_HPP |
|
||||||
#define MONOFORMAT_SCHEMA_HPP |
|
||||||
|
|
||||||
#include <cstddef> |
|
||||||
#include <cstdint> |
|
||||||
#include <span> |
|
||||||
|
|
||||||
namespace monoformat { |
|
||||||
|
|
||||||
enum class SectionType { |
|
||||||
AlwaysDrawn = 1, |
|
||||||
TimeBasedDrawn = 2, |
|
||||||
CustomFont = 32, |
|
||||||
}; |
|
||||||
|
|
||||||
enum class ElementType { |
|
||||||
Image = 1, |
|
||||||
Animation = 2, |
|
||||||
HScrollImage = 3, |
|
||||||
VScrollImage = 4, |
|
||||||
Line = 5, |
|
||||||
ClippedText = 16, |
|
||||||
HScrollText = 17, |
|
||||||
//VScrollText = 18,
|
|
||||||
CurrentTime = 32, |
|
||||||
}; |
|
||||||
|
|
||||||
enum class LineStyle : std::uint8_t { |
|
||||||
Solid = 0, |
|
||||||
}; |
|
||||||
|
|
||||||
struct OneBitBufferInterface { |
|
||||||
using Color = bool; |
|
||||||
|
|
||||||
virtual ~OneBitBufferInterface() = default; |
|
||||||
virtual bool isPixelSet(std::uint16_t x, std::uint16_t y) const = 0; |
|
||||||
virtual void setPixel(std::uint16_t x, std::uint16_t y, bool value) = 0; |
|
||||||
}; |
|
||||||
|
|
||||||
struct MemoryOneBitBuffer : public OneBitBufferInterface { |
|
||||||
MemoryOneBitBuffer(std::span<std::byte> buffer, std::uint16_t width, std::uint16_t height); |
|
||||||
virtual ~MemoryOneBitBuffer() override; |
|
||||||
virtual bool isPixelSet(std::uint16_t x, std::uint16_t y) const override; |
|
||||||
virtual void setPixel(std::uint16_t x, std::uint16_t y, bool value) override; |
|
||||||
private: |
|
||||||
std::uint16_t m_width{}; |
|
||||||
std::uint16_t m_height{}; |
|
||||||
std::span<std::byte> m_buffer; |
|
||||||
}; |
|
||||||
|
|
||||||
struct ConstMemoryOneBitBuffer : public OneBitBufferInterface { |
|
||||||
ConstMemoryOneBitBuffer(std::span<std::byte const> buffer, std::uint16_t width, std::uint16_t height); |
|
||||||
virtual ~ConstMemoryOneBitBuffer() override; |
|
||||||
virtual bool isPixelSet(std::uint16_t x, std::uint16_t y) const override; |
|
||||||
virtual void setPixel(std::uint16_t x, std::uint16_t y, bool value) override; |
|
||||||
private: |
|
||||||
std::uint16_t m_width{}; |
|
||||||
std::uint16_t m_height{}; |
|
||||||
std::span<std::byte const> m_buffer; |
|
||||||
}; |
|
||||||
|
|
||||||
struct ClippedImage : public OneBitBufferInterface { |
|
||||||
ClippedImage(OneBitBufferInterface* underlying, std::uint16_t x, std::uint16_t y, std::uint16_t width, std::uint16_t height); |
|
||||||
virtual ~ClippedImage() override; |
|
||||||
virtual bool isPixelSet(std::uint16_t x, std::uint16_t y) const override; |
|
||||||
virtual void setPixel(std::uint16_t x, std::uint16_t y, bool value) override; |
|
||||||
private: |
|
||||||
OneBitBufferInterface* m_underlying{}; |
|
||||||
std::uint16_t m_x{}; |
|
||||||
std::uint16_t m_y{}; |
|
||||||
std::uint16_t m_width{}; |
|
||||||
std::uint16_t m_height{}; |
|
||||||
}; |
|
||||||
|
|
||||||
} // namespace monoformat
|
|
||||||
|
|
||||||
#endif // MONOFORMAT_SCHEMA_HPP
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,201 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
namespace monoformat { |
|
||||||
|
|
||||||
enum SectionType : int { |
|
||||||
case AlwaysDrawn = 1; |
|
||||||
case TimeBasedDrawn = 2; |
|
||||||
case CustomFont = 32; |
|
||||||
} |
|
||||||
|
|
||||||
enum ElementType : int { |
|
||||||
case Image = 1; |
|
||||||
case Animation = 2; |
|
||||||
case HScrollImage = 3; |
|
||||||
case VScrollImage = 4; |
|
||||||
case Line = 5; |
|
||||||
case ClippedText = 16; |
|
||||||
case HScrollText = 17; |
|
||||||
case CurrentTime = 32; |
|
||||||
} |
|
||||||
|
|
||||||
enum LineStyle : int { |
|
||||||
case Solid = 0; |
|
||||||
} |
|
||||||
|
|
||||||
class Element { |
|
||||||
public function serialize() { |
|
||||||
return ""; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
class HScrollTextElement extends Element { |
|
||||||
public $x = 0; |
|
||||||
public $y = 0; |
|
||||||
public $width = 0; |
|
||||||
public $height = 0; |
|
||||||
public $flags = 0; |
|
||||||
public $scrollSpeed = 0; |
|
||||||
public $fontIndex = 0; |
|
||||||
public $text = ""; |
|
||||||
|
|
||||||
public function serialize() { |
|
||||||
$len = strlen($this->text); |
|
||||||
$result = pack("vvvvvCCvv", |
|
||||||
17, |
|
||||||
$this->x, |
|
||||||
$this->y, |
|
||||||
$this->width, |
|
||||||
$this->height, |
|
||||||
$this->flags, |
|
||||||
$this->scrollSpeed, |
|
||||||
$this->fontIndex, |
|
||||||
$len); |
|
||||||
$result .= (string) $this->text; |
|
||||||
if ($len % 4 != 0) { |
|
||||||
$n = 4 - ($len % 4); |
|
||||||
for ($i = 0; $i < $n; ++$i) { |
|
||||||
$result .= chr(0); |
|
||||||
} |
|
||||||
} |
|
||||||
return $result; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
class CurrentTimeElement extends Element { |
|
||||||
public $x = 0; |
|
||||||
public $y = 0; |
|
||||||
public $width = 0; |
|
||||||
public $height = 0; |
|
||||||
public $fontIndex = 0; |
|
||||||
public $utcOffset = 0; |
|
||||||
public $flags = 0; |
|
||||||
|
|
||||||
public function serialize() { |
|
||||||
$result = pack("vvvvvvvv", |
|
||||||
32, |
|
||||||
$this->x, |
|
||||||
$this->y, |
|
||||||
$this->width, |
|
||||||
$this->height, |
|
||||||
$this->fontIndex, |
|
||||||
$this->utcOffset, |
|
||||||
$this->flags); |
|
||||||
return $result; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
class Section { |
|
||||||
public function serialize() { |
|
||||||
return ""; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
class AlwaysDrawnSection extends Section { |
|
||||||
public $drawOnFront = false; |
|
||||||
public $drawOnBack = false; |
|
||||||
public $clearBeforeDrawing = false; |
|
||||||
public $elements = []; |
|
||||||
|
|
||||||
public function serialize() { |
|
||||||
$flags = 0; |
|
||||||
if ($this->drawOnFront) { |
|
||||||
$flags |= 0x01; |
|
||||||
} |
|
||||||
if ($this->drawOnBack) { |
|
||||||
$flags |= 0x02; |
|
||||||
} |
|
||||||
if ($this->clearBeforeDrawing) { |
|
||||||
$flags |= 0x04; |
|
||||||
} |
|
||||||
$inner = pack("vv", $flags, count($this->elements)); |
|
||||||
foreach ($this->elements as $element) { |
|
||||||
$inner .= $element->serialize(); |
|
||||||
} |
|
||||||
$len = strlen($inner) + 4; |
|
||||||
$len = substr(pack("V", $len), 0, 3); |
|
||||||
return pack("C", 1) . $len . $inner; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
class File { |
|
||||||
public $sections = []; |
|
||||||
|
|
||||||
public function serialize() { |
|
||||||
$nSections = count($this->sections); |
|
||||||
$result = "\xAF\x7E\x2B\x63"; |
|
||||||
$result .= pack("Vvv", 1, $nSections, 0); |
|
||||||
foreach ($this->sections as $section) { |
|
||||||
$result .= $section->serialize(); |
|
||||||
} |
|
||||||
return $result; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} // namespace monoformat |
|
||||||
|
|
||||||
namespace { |
|
||||||
|
|
||||||
$roomName= "BOOL"; |
|
||||||
|
|
||||||
$data = json_decode(file_get_contents("https://cfp.cttue.de/tdf5/schedule/export/schedule.json"), true); |
|
||||||
$talks = []; |
|
||||||
$now = new DateTimeImmutable("now"); |
|
||||||
foreach ($data["schedule"]["conference"]["days"] as $day) { |
|
||||||
foreach ($day["rooms"][$roomName] as $t) { |
|
||||||
[$h, $m] = explode(":", $t["duration"]); |
|
||||||
$duration = $h * 3600 + $m * 60; |
|
||||||
$duration = DateInterval::createFromDateString("$duration sec"); |
|
||||||
$talk = [ |
|
||||||
"date" => new DateTimeImmutable($t["date"]), |
|
||||||
"duration" => $duration, |
|
||||||
"title" => $t["title"], |
|
||||||
]; |
|
||||||
$talkEnd = $talk["date"]->add($talk["duration"]); |
|
||||||
if ($talkEnd < $now) { |
|
||||||
continue; |
|
||||||
} |
|
||||||
if ($talk["date"] > $now && count($talks) > 2) { |
|
||||||
break; |
|
||||||
} |
|
||||||
array_push($talks, $talk); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
$elements = []; |
|
||||||
|
|
||||||
function putText($x, $y, $width, $height, $text) { |
|
||||||
global $elements; |
|
||||||
|
|
||||||
$e = new monoformat\HScrollTextElement(); |
|
||||||
$e->x = $x; |
|
||||||
$e->y = $y; |
|
||||||
$e->width = $width; |
|
||||||
$e->height = $height; |
|
||||||
$e->flags = 0; |
|
||||||
$e->scrollSpeed = 15; |
|
||||||
$e->fontIndex = 0; |
|
||||||
$e->text = $text; |
|
||||||
array_push($elements, $e); |
|
||||||
} |
|
||||||
|
|
||||||
$i = 0; |
|
||||||
foreach ($talks as $talk) { |
|
||||||
putText(10, $i * 20, 25, 20, $talk["date"]->format("H:i")); |
|
||||||
putText(35, $i * 20, 85, 20, $talk["title"]); |
|
||||||
++$i; |
|
||||||
} |
|
||||||
|
|
||||||
$section = new monoformat\AlwaysDrawnSection(); |
|
||||||
$section->drawOnFront = true; |
|
||||||
$section->drawOnBack = true; |
|
||||||
$section->clearBeforeDrawing = true; |
|
||||||
$section->elements = $elements; |
|
||||||
|
|
||||||
$file = new monoformat\File(); |
|
||||||
array_push($file->sections, $section); |
|
||||||
|
|
||||||
print($file->serialize()); |
|
||||||
} // global |
|
||||||
|
|
||||||
?> |
|
||||||
Loading…
Reference in new issue