The original library from Dan is not working as expected for me. So I adopted the code a little bit.

You can find the changes below. You can also download "my version" of the library here. Unzip into the Arduino's library folder.

 INextionWidget.cpp

bool INextionWidget::sendCommand(char *commandStr, bool checkComplete) {
  // if (m_pageID != m_nextion.getCurrentPage()) return false;

  m_nextion.sendCommand(commandStr);

  if (checkComplete)
    return m_nextion.checkCommandComplete();
  else
    return true;
}

Nextion.cpp

/*!
 * \brief Initialises the device.
 * \return True if initialisation was successful.
 */
bool Nextion::init()
{
  while ( m_serialPort.read() != -1 ) ;

  sendCommand("");

  sendCommand("bkcmd=0");
  bool result1 = checkCommandComplete();

  sendCommand("page 0");
  bool result2 = checkCommandComplete();

  return (result1 && result2);
}

/*!
 * \brief Checks if the last command was successful.
 * \return True if command was successful
 */
bool Nextion::checkCommandComplete() {
  return true;
}

2014 CW (Morse Telegraphy) was added to the German Nationwide Inventory of Intangible Cultural Heritage.

Logo