API
Nextion Constants
Const
This file contains the constant definitions of all Nextion commands
- nextion.const.NEX_END_CMD = b'\xff\xff\xff'
End command
- nextion.const.NEX_RET_CMD_FINISHED = <Mock name='mock.const()' id='140221200069680'>
Command finished
- nextion.const.NEX_RET_CURRENT_PAGE_ID_HEAD = <Mock name='mock.const()' id='140221200069680'>
Current page ID head
- nextion.const.NEX_RET_EVENT_LAUNCHED = <Mock name='mock.const()' id='140221200069680'>
Event launched
- nextion.const.NEX_RET_EVENT_POSITION_HEAD = <Mock name='mock.const()' id='140221200069680'>
Event position head
- nextion.const.NEX_RET_EVENT_SLEEP_POSITION_HEAD = <Mock name='mock.const()' id='140221200069680'>
Event sleep position head
- nextion.const.NEX_RET_EVENT_TOUCH_HEAD = <Mock name='mock.const()' id='140221200069680'>
Event touch head
- nextion.const.NEX_RET_EVENT_UPGRADED = <Mock name='mock.const()' id='140221200069680'>
Event upgraded
- nextion.const.NEX_RET_INVALID_BAUD = <Mock name='mock.const()' id='140221200069680'>
Invalid baudrate
- nextion.const.NEX_RET_INVALID_CMD = <Mock name='mock.const()' id='140221200069680'>
Invalid command
- nextion.const.NEX_RET_INVALID_COMPONENT_ID = <Mock name='mock.const()' id='140221200069680'>
Invalid component ID
- nextion.const.NEX_RET_INVALID_FONT_ID = <Mock name='mock.const()' id='140221200069680'>
Invalid font ID
- nextion.const.NEX_RET_INVALID_OPERATION = <Mock name='mock.const()' id='140221200069680'>
Invalid operation
- nextion.const.NEX_RET_INVALID_PAGE_ID = <Mock name='mock.const()' id='140221200069680'>
Invalid page ID
- nextion.const.NEX_RET_INVALID_PICTURE_ID = <Mock name='mock.const()' id='140221200069680'>
Invalid picture ID
- nextion.const.NEX_RET_INVALID_VARIABLE = <Mock name='mock.const()' id='140221200069680'>
Invalid variable
- nextion.const.NEX_RET_NUMBER_HEAD = <Mock name='mock.const()' id='140221200069680'>
Number head
- nextion.const.NEX_RET_STRING_HEAD = <Mock name='mock.const()' id='140221200069680'>
String head
Common module
Common
Common functions shared accross all Nextion elements
Check the description of Mixin https://realpython.com/lessons/multiple-inheritance-python/
- class nextion.common.Common(nh, pid: int, cid: int, name: str)[source]
Bases:
objectdocstring for Common
- class nextion.common.CommonBackgroundColorMixin[source]
Bases:
objectdocstring for CommonBackgroundColorMixin
- exception nextion.common.CommonError[source]
Bases:
ExceptionBase class for exceptions in this module.
- class nextion.common.CommonFontMixin[source]
Bases:
objectdocstring for CommonFontMixin
- Get_font_color_pco() int[source]
Get font color attribute of component
- Returns
The font color
- Return type
- class nextion.common.CommonPointerMixin[source]
Bases:
objectdocstring for CommonPointerMixin
- class nextion.common.CommonPositionMixin[source]
Bases:
objectdocstring for CommonPositionMixin
Checkbox
NexCheckbox
Functions to interact with a Nextion Checkbox element
- class nextion.nextion_checkbox.NexCheckbox(nh, pid: int, cid: int, name: str)[source]
Bases:
Common,CommonBackgroundColorMixin,CommonFontMixin,CommonValueMixindocstring for NexCheckbox
Gauge
NexGauge
Functions to interact with a Nextion Gauge element
- class nextion.nextion_gauge.NexGauge(nh, pid: int, cid: int, name: str)[source]
Bases:
Common,CommonBackgroundColorMixin,CommonFontMixin,CommonPointerMixin,CommonValueMixindocstring for NexGauge
GPIO
NexGpio
Functions to interact with Nextion GPIOs
- class nextion.nextion_gpio.NexGpio(nh)[source]
Bases:
Commondocstring for NexGpio
Hardware
Common
This class performs the basic and common interactions with the Nextion display
- Known issues
sendCommand uses the default timeout, but should use timeout = 0 https://github.com/micropython/micropython/issues/3434
- class nextion.nextion_hardware.NexHardware(rx_pin: int, tx_pin: int, uart_id: int = 1, baudrate: None = 9600, timeout: None = 100, invert: None = 0, logger: None = None)[source]
Bases:
objectdocstring for NexHardware
- brightness(value: int) None[source]
Set brightness of display
- Parameters
value (int) – The value in percent [0, 100]
- static create_logger(logger_name: None = None) Logger[source]
Create a logger.
- Parameters
logger_name (str, optional) – The logger name
- Returns
Configured logger
- Return type
- nexInit() bool[source]
Init Nextion interface to display
- Returns
Result of init, True on success, False otherwise
- Return type
Number
NexNumber
Functions to interact with a Nextion Number element
- class nextion.nextion_number.NexNumber(nh, pid: int, cid: int, name: str)[source]
Bases:
Common,CommonBackgroundColorMixin,CommonFontMixin,CommonPositionMixin,CommonValueMixindocstring for NexNumber
Page
NexPage
Functions to interact with a Nextion Page element
Progressbar
NexProgressBar
Functions to interact with a Nextion Progressbar element
- class nextion.nextion_progressbar.NexProgressBar(nh, pid: int, cid: int, name: str)[source]
Bases:
Common,CommonBackgroundColorMixin,CommonFontMixin,CommonValueMixindocstring for NexProgressBar
Radio Button
NexRadio
Functions to interact with a Nextion Radio element
- class nextion.nextion_radio.NexRadio(nh, pid: int, cid: int, name: str)[source]
Bases:
Common,CommonBackgroundColorMixin,CommonFontMixin,CommonValueMixindocstring for NexRadio
RTC
NexRtc
Functions to interact with Nextion RTC
Scrolltext
Slider
NexSlider
Functions to interact with a Nextion Slider element
- class nextion.nextion_slider.NexSlider(nh, pid: int, cid: int, name: str)[source]
Bases:
Common,CommonBackgroundColorMixin,CommonFontMixin,CommonPointerMixin,CommonValueMixindocstring for NexSlider
- Get_cursor_height_hig() int[source]
Get cursor hig attribute of component
- Returns
The cursor height.
- Return type
number
Text
NexText
Functions to interact with a Nextion Text element
- class nextion.nextion_text.NexText(nh, pid: int, cid: int, name: str)[source]
Bases:
Common,CommonBackgroundColorMixin,CommonFontMixin,CommonPositionMixin,CommonTextMixindocstring for NexText
Upload
NexUpload
Functions to download TFT file to Nextion display
- class nextion.nextion_upload.NexUpload(nh, file_name: str, download_baudrate: int)[source]
Bases:
Commondocstring for NexUpload
- _checkFile() bool[source]
Check existance of specified TFT file
- Returns
True on success, False otherwise
- Return type
- _downloadTftFile() bool[source]
Download TFT file to Nextion display
- Returns
True on success, False otherwise
- Return type
- _getBaudrate() int[source]
Get communication baudrate with Nextion display
- Returns
The baudrate
- Return type
- property download_baudrate: int
Get the download baudrate
- Returns
Download baudrate for communication with Nextion display
- Return type
Variable
NexVariable
Functions to interact with a Nextion Variable element
- class nextion.nextion_variable.NexVariable(nh, pid: int, cid: int, name: str)[source]
Bases:
Common,CommonTextMixin,CommonValueMixindocstring for NexVariable
Waveform
NexWaveform
Functions to interact with a Nextion Waveform element
- class nextion.nextion_waveform.NexWaveform(nh, pid: int, cid: int, name: str)[source]
Bases:
Common,CommonBackgroundColorMixin,CommonFontMixindocstring for NexWaveform
- Get_channel_0_color_pco0() int[source]
Get channel0 pco0 attribute of component
- Returns
The channel0 pco0
- Return type
- Get_grid_color_gdc() int[source]
Get grid color attribute of component
- Returns
The grid color
- Return type
- Get_grid_height_gdh() int[source]
Get grid height attribute of component
- Returns
The grid height
- Return type
- Get_grid_width_gdw() int[source]
Get grid width attribute of component
- Returns
The grid width
- Return type