Skip to main content

DisplaySettings

Struct DisplaySettings 

Source
pub struct DisplaySettings {
    pub columns: usize,
    pub rows: usize,
    pub encoding: TextEncoding,
    pub code_table: Option<u8>,
    pub reset_on_open: bool,
    pub brightness: Option<RangeInclusive<u8>>,
    pub brightness_settle: Duration,
}
Expand description

Настройки геометрии и ESC/POS-команд дисплея.

columns и rows задают координатную сетку, используемую для проверки print_line и print_at. code_table управляет только аппаратной командой ESC t n, а encoding определяет программное преобразование текста в байты.

Fields§

§columns: usize

Количество символов в строке.

Допустимый диапазон: 1..=255. Значение используется для обрезки, заполнения пробелами и проверки координаты x.

§rows: usize

Количество строк.

Допустимый диапазон: 1..=255. Значение используется для проверки line и y во всех методах печати.

§encoding: TextEncoding

Кодировка текстовых байтов.

Это программное преобразование Rust-строки в байты транспорта. Оно не выбирает аппаратную таблицу дисплея.

§code_table: Option<u8>

Таблица символов для ESC t n; None отключает отправку команды.

Это отдельная аппаратная команда протокола. Для многих дисплеев CP866 работает только когда одновременно выбраны encoding = TextEncoding::Cp866 и нужное значение code_table.

§reset_on_open: bool

Отправлять ESC @ при открытии.

Сброс полезен для predictable startup, но его можно выключить, если приложение намеренно сохраняет состояние дисплея между открытиями.

§brightness: Option<RangeInclusive<u8>>

Поддерживаемый диапазон яркости для US X n.

None означает, что типизированная установка яркости запрещена и crate::Vfd::set_brightness вернёт crate::VfdError::UnsupportedBrightness.

§brightness_settle: Duration

Задержка после изменения яркости.

Некоторые дисплеи требуют короткую паузу после US X n. Sync API блокирует текущий поток на это время; Tokio API ждёт через async sleep.

Implementations§

Source§

impl DisplaySettings

Source

pub fn new(columns: usize, rows: usize, encoding: TextEncoding) -> Self

Создаёт ручные настройки дисплея.

По умолчанию включён ESC @ при открытии, яркость 1..=4 и короткая задержка после её изменения. Аппаратная таблица символов не выбирается автоматически: задайте code_table = Some(n), если вашему дисплею нужна команда ESC t n.

§Ошибки

Метод сам не возвращает ошибку. Проверка выполняется в DisplaySettings::validate или при создании VfdConfig.

§Примеры
use escpos_vfd::{DisplaySettings, TextEncoding};

let mut display = DisplaySettings::new(20, 2, TextEncoding::Cp866);
display.code_table = Some(6);
assert!(display.validate().is_ok());
Source

pub fn validate(&self) -> Result<(), ConfigError>

Проверяет геометрию и диапазоны настроек дисплея.

§Ошибки

Возвращает ConfigError::InvalidColumns, ConfigError::InvalidRows или ConfigError::InvalidBrightnessRange.

Trait Implementations§

Source§

impl Clone for DisplaySettings

Source§

fn clone(&self) -> DisplaySettings

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DisplaySettings

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for DisplaySettings

Source§

impl PartialEq for DisplaySettings

Source§

fn eq(&self, other: &DisplaySettings) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DisplaySettings

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.