Commit 15b81c00 authored by MagoKimbra's avatar MagoKimbra

Update 4.2.5

parent 85ada325
......@@ -30,7 +30,7 @@
// Enable the Bluetooth serial interface
//#define BLUETOOTH
#define BLUETOOTH_SERIAL 1
#define BLUETOOTH_PORT 1
#define BLUETOOTH_BAUD 115200
// User-specified version info of this build to display in [Pronterface, etc] terminal window during
......
......@@ -49,6 +49,7 @@
* - Filament diameter sensor
* - Filament Runout sensor
* - Power consumption sensor
* - RFID card sensor
* ADDON FEATURES:
* - EEPROM
* - SDCARD
......@@ -322,7 +323,7 @@
// Extruder cooling fans
// Configure fan pin outputs to automatically turn on/off when the associated
// extruder temperature is above/below EXTRUDER_AUTO_FAN_TEMPERATURE.
// extruder temperature is above/below EXTRUDER AUTO FAN TEMPERATURE.
// Multiple extruders can be assigned to the same pin in which case
// the fan will turn on when any selected extruder is above the threshold.
// You need to set _AUTO_FAN_PIN in Configuration_pins.h
......@@ -1150,9 +1151,9 @@
// http://reprap.org/wiki/Mini_panel
//#define MINIPANEL
// Nextion HMI panel
// REMEMBER TO INSTALL Nextion library in your ARDUINO library folder. You can find it in Arduino/libraries/
// Nextion HMI panel Serial
//#define NEXTION
#define NEXTION_PORT 1
// For GFX Visualization enable Nextion GFX
//#define NEXTION_GFX
......
/**
* Configuration_Overall.h
* Here you can define all your custom settings and they will overwrite configurations in the main configuration files.
* Decomment or comment CONFIGURATION OVERALL ON for active or deactive this file.
*/
//#define CONFIGURATION_OVERALL_ON
......@@ -133,7 +133,7 @@
#endif
#if ENABLED(Z_PROBE_ENDSTOP)
#define Z_PROBE_PIN -1
#define Z_PROBE_PIN ORIG_Z_MIN_PIN
#endif
//============================================================================
......
......@@ -410,7 +410,7 @@ void Config_RetrieveSettings() {
updatePID();
// Report settings retrieved and length
ECHO_ST(DB, ver);
ECHO_SV(DB, ver);
ECHO_MV(" stored settings retrieved (", (unsigned long)i);
ECHO_EM(" bytes)");
}
......
......@@ -22,7 +22,9 @@ FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_Prin
#if ENABLED(SDSUPPORT) && ENABLED(SD_SETTINGS)
#define CFG_SD_MAX_KEY_LEN 3+1 // icrease this if you add key name longer than the actual value.
#define CFG_SD_MAX_VALUE_LEN 30+1 // this should be enought for int, long and float if you need to retrive strings increase this carefully
#define CFG_SD_MAX_VALUE_LEN 10+1 // this should be enought for int, long and float if you need to retrive strings increase this carefully
//(11 = strlen("4294967295")+1) (4294967295 = (2^32)-1) (32 = the num of bits of the bigger basic data scructor used)
//If yuou need to save string increase this to strlen("YOUR LONGER STRING")+1
void ConfigSD_StoreSettings();
void ConfigSD_RetrieveSettings(bool addValue = false);
int ConfigSD_KeyIndex(char *key);
......
......@@ -2,7 +2,7 @@
* MK Firmware
*
* Based on Marlin, Sprinter and grbl
* Copyright (C) 2013 MK
* Copyright (C) 2013 MagoKimbra
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
......
......@@ -11,13 +11,16 @@
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#define ENABLED defined
#define DISABLED !defined
#include "Boards.h"
#include "module/mechanics.h"
#include "Configuration_Version.h"
#include "Configuration_Overall.h"
#ifndef CONFIGURATION_OVERALL_ON
#if DISABLED(CONFIGURATION_OVERALL_ON)
#include "Configuration_Basic.h"
#if MECH(CARTESIAN)
......
......@@ -54,8 +54,6 @@
#define COS_60 0.5
// Macros to support option testing
#define ENABLED defined
#define DISABLED !defined
#define PIN_EXISTS(PN) (defined(PN##_PIN) && PN##_PIN >= 0)
#define HAS(FE) (HAS_##FE)
#define HASNT(FE) (!(HAS_##FE))
......
......@@ -23,7 +23,7 @@
#define HardwareSerial_H
#define clear_bit(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#define set_bit(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#define set_bit(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
// The presence of the UBRRH register is used to detect a UART.
#define UART_PRESENT(port) ((port == 0 && (defined(UBRRH) || defined(UBRR0H))) || \
......
......@@ -2805,7 +2805,7 @@ void gcode_get_destination() {
}
void unknown_command_error() {
ECHO_LMT(ER, SERIAL_UNKNOWN_COMMAND, current_command);
ECHO_LMV(ER, SERIAL_UNKNOWN_COMMAND, current_command);
}
/**
......@@ -5388,6 +5388,7 @@ inline void gcode_M140() {
*
* T<extruder> - Optional extruder number. Current extruder if omitted.
* D<mm> - Diameter of the filament. Use "D0" to set units back to millimetres.
* S<0/1> - Deactivate o Activate volumetric
*/
inline void gcode_M200() {
......@@ -5399,17 +5400,25 @@ inline void gcode_M200() {
// slicers either generate in extruder values as cubic mm or as as filament feeds
// for all extruders
volumetric_enabled = (diameter != 0.0);
if (volumetric_enabled) {
filament_size[target_extruder] = diameter;
// make sure all extruders have some sane value for the filament size
for (int i = 0; i < EXTRUDERS; i++)
if (!filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
}
filament_size[target_extruder] = diameter;
}
else {
//reserved for setting filament diameter via UFID or filament measuring device
return;
if (code_seen('S')) {
if (code_value())
volumetric_enabled = true;
else
volumetric_enabled = false;
}
if (volumetric_enabled) {
ECHO_LM(INFO, "Volumetric Enabled");
// make sure all extruders have some sane value for the filament size
for (int i = 0; i < EXTRUDERS; i++)
if (!filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
}
else
ECHO_LM(INFO, "Volumetric Disabled");
calculate_volumetric_multipliers();
}
......@@ -8231,7 +8240,7 @@ bool setTargetedExtruder(int code) {
float calculate_volumetric_multiplier(float diameter) {
if (!volumetric_enabled || diameter == 0) return 1.0;
float d2 = diameter * 0.5;
return 100.0 / (M_PI * d2 * d2);
return 1.0 / (M_PI * d2 * d2);
}
void calculate_volumetric_multipliers() {
......
......@@ -13,7 +13,7 @@ static char serial_answer;
void FirmwareTest() {
ECHO_EM("---------- FIRMWARE TEST --------------");
ECHO_EM("--------- by MarlinKimbra -------------");
ECHO_EM("--------------- MK --------------------");
ECHO_EV(MSG_FWTEST_01);
ECHO_EV(MSG_FWTEST_02);
ECHO_EV(MSG_FWTEST_YES_NO);
......
......@@ -33,6 +33,7 @@
#define MSG_SET_ORIGIN "Establir zero"
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Prec."
#define MSG_CONGIG "conf."
#define MSG_PREHEAT_PLA MSG_PREHEAT " PLA"
......
......@@ -33,6 +33,7 @@
#define MSG_SET_ORIGIN "Изходна точка"
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Подгр."
#define MSG_CONGIG "Настр."
#define MSG_PREHEAT_PLA MSG_PREHEAT " PLA"
......
......@@ -33,6 +33,7 @@
#define MSG_SET_ORIGIN "Establir origen"
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Preesc."
#define MSG_PREHEAT_PLA MSG_PREHEAT " PLA"
#define MSG_PREHEAT_PLA_ALL MSG_PREHEAT_PLA " All"
......
......@@ -33,6 +33,7 @@
#define MSG_SET_ORIGIN "\xbe\xbf\xbc\xbd"
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "\xc3\xc4"
#define MSG_PREHEAT_PLA MSG_PREHEAT " PLA"
#define MSG_PREHEAT_PLA_ALL MSG_PREHEAT_PLA " \xc5\xc6"
......
......@@ -33,6 +33,7 @@
#define MSG_SET_ORIGIN "Set origin"
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Forvarm"
#define MSG_PREHEAT_PLA MSG_PREHEAT " PLA"
#define MSG_PREHEAT_PLA_ALL MSG_PREHEAT_PLA " Alle"
......
......@@ -33,6 +33,7 @@
#define MSG_SET_ORIGIN "Setze Null hier"
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Vorwärmen"
#define MSG_PREHEAT_PLA MSG_PREHEAT " PLA"
#define MSG_PREHEAT_PLA_ALL MSG_PREHEAT_PLA " All"
......
......@@ -33,6 +33,7 @@
#define MSG_SET_ORIGIN "Set origin"
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Preheat"
#define MSG_PREHEAT_PLA MSG_PREHEAT " PLA"
#define MSG_PREHEAT_PLA_ALL MSG_PREHEAT_PLA " All"
......
......@@ -33,6 +33,7 @@
#define MSG_SET_ORIGIN "Establecer cero"
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Precalentar"
#define MSG_PREHEAT_PLA MSG_PREHEAT " PLA"
#define MSG_PREHEAT_PLA_ALL MSG_PREHEAT_PLA " All"
......
......@@ -33,6 +33,7 @@
#define MSG_SET_ORIGIN "Hasiera ipini"
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Berotu"
#define MSG_PREHEAT_PLA MSG_PREHEAT " PLA"
#define MSG_PREHEAT_PLA_ALL MSG_PREHEAT_PLA " Guztia"
......
......@@ -33,6 +33,7 @@
#define MSG_SET_ORIGIN "Aseta origo"
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Preheat"
#define MSG_PREHEAT_PLA MSG_PREHEAT " PLA"
#define MSG_PREHEAT_PLA_ALL MSG_PREHEAT_PLA " All"
......
......@@ -33,6 +33,7 @@
#define MSG_SET_ORIGIN "Regler origine"
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Prech."
#define MSG_PREHEAT_PLA MSG_PREHEAT " PLA"
#define MSG_PREHEAT_PLA_ALL MSG_PREHEAT_PLA " Tout"
......
......@@ -33,6 +33,7 @@
#define MSG_SET_ORIGIN "Imposta Origine"
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.za:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Preriscalda"
#define MSG_PREHEAT_PLA "Preriscalda PLA"
#define MSG_PREHEAT_PLA_ALL "Prer. PLA Tutto"
......
......@@ -35,6 +35,7 @@
#define MSG_SET_ORIGIN "\xb7\xbc\xde\xad\xdd\xbe\xaf\xc4" // "Set origin"
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Preheat"
#define MSG_PREHEAT_PLA "PLA \xd6\xc8\xc2"
#define MSG_PREHEAT_PLA_ALL MSG_PREHEAT_PLA " \xbd\xcd\xde\xc3" // " All"
......
......@@ -38,6 +38,7 @@
#define MSG_SET_ORIGIN "キヅユンセツト" // "Set origin"
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Preheat"
#define MSG_PREHEAT_PLA "PLA ヨネシ" // "Preheat PLA"
#define MSG_PREHEAT_PLA_ALL MSG_PREHEAT_PLA " スベテ" // " All"
......
......@@ -33,6 +33,7 @@
#define MSG_SET_ORIGIN "Nulpunt instellen"
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Preheat"
#define MSG_PREHEAT_PLA "PLA voorverwarmen"
#define MSG_PREHEAT_PLA_ALL "PLA voorverw. aan"
......
......@@ -33,6 +33,7 @@
#define MSG_SET_ORIGIN "Ustaw punkt zero"
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Preheat"
#define MSG_PREHEAT_PLA "Rozgrzej PLA"
#define MSG_PREHEAT_PLA_ALL "Roz. PLA Wszystko"
......
......@@ -33,6 +33,7 @@
#define MSG_SET_ORIGIN "Estabelecer orig."
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Pre-aq."
#define MSG_PREHEAT_PLA MSG_PREHEAT " PLA"
#define MSG_PREHEAT_PLA_ALL MSG_PREHEAT_PLA " Tudo"
......
......@@ -33,6 +33,7 @@
#define MSG_SET_ORIGIN "Estabelecer orig."
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Pre-aq."
#define MSG_PREHEAT_PLA MSG_PREHEAT " PLA"
#define MSG_PREHEAT_PLA_ALL MSG_PREHEAT_PLA " Tudo"
......
......@@ -33,6 +33,7 @@
#define MSG_SET_ORIGIN "Запомнить ноль"
#define MSG_ONFOR "On x:"
#define MSG_PWRCONSUMED "P.er:"
#define MSG_FILCONSUMED "F:"
#define MSG_PREHEAT "Преднаг"
#define MSG_PREHEAT_PLA MSG_PREHEAT " PLA"
#define MSG_PREHEAT_PLA_ALL MSG_PREHEAT_PLA " все"
......
......@@ -1132,6 +1132,13 @@ static void lcd_stats_menu() {
sprintf_P(row, PSTR(MSG_PWRCONSUMED " %iWh"), power_consumption_hour);
LCD_Printpos(0, 1); lcd_print(row);
#endif
char lung[30];
unsigned int kmeter = (long)printer_usage_filament / 1000 / 1000,
meter = ((long)printer_usage_filament / 1000) % 1000,
centimeter = ((long)printer_usage_filament / 10) % 100,
millimeter = ((long)printer_usage_filament) % 10;
sprintf_P(lung, PSTR(MSG_FILCONSUMED "%i Km %i m %i cm %i mm"), kmeter, meter, centimeter, millimeter);
LCD_Printpos(0, 2); lcd_print(lung);
if (LCD_CLICKED) lcd_goto_menu(lcd_main_menu);
}
......
/**
* @file NexButton.cpp
*
* The implementation of class NexButton.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#include "NexButton.h"
NexButton::NexButton(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
uint16_t NexButton::getText(char *buffer, uint16_t len)
{
String cmd;
cmd += "get ";
cmd += getObjName();
cmd += ".txt";
sendCommand(cmd.c_str());
return recvRetString(buffer,len);
}
bool NexButton::setText(const char *buffer)
{
String cmd;
cmd += getObjName();
cmd += ".txt=\"";
cmd += buffer;
cmd += "\"";
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
/**
* @file NexButton.h
*
* The definition of class NexButton.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#ifndef __NEXBUTTON_H__
#define __NEXBUTTON_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexButton component.
*
* Commonly, you want to do something after push and pop it. It is recommanded that only
* call @ref NexTouch::attachPop to satisfy your purpose.
*
* @warning Please do not call @ref NexTouch::attachPush on this component, even though you can.
*/
class NexButton: public NexTouch
{
public: /* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexButton(uint8_t pid, uint8_t cid, const char *name);
/**
* Get text attribute of component.
*
* @param buffer - buffer storing text returned.
* @param len - length of buffer.
* @return The real length of text returned.
*/
uint16_t getText(char *buffer, uint16_t len);
/**
* Set text attribute of component.
*
* @param buffer - text buffer terminated with '\0'.
* @return true if success, false for failure.
*/
bool setText(const char *buffer);
};
/**
* @}
*/
#endif /* #ifndef __NEXBUTTON_H__ */
/**
* @file NexConfig.h
*
* Options for user can be found here.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#include "../../base.h"
#ifndef __NEXCONFIG_H__
#define __NEXCONFIG_H__
#if NEXTION_SERIAL > 0
#if NEXTION_SERIAL == 1
#define nexSerial Serial1
#elif NEXTION_SERIAL == 2
#define nexSerial Serial2
#elif NEXTION_SERIAL == 3
#define nexSerial Serial3
#endif
#else
#define nexSerial Serial1
#endif
#define dbSerialPrint(a) {}
#define dbSerialPrintln(a) {}
#define dbSerialBegin(a) {}
#endif //__NEXCONFIG_H__
/**
* @file NexCrop.cpp
*
* The implementation of class NexCrop.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#include "NexCrop.h"
NexCrop::NexCrop(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
bool NexCrop::getPic(uint32_t *number)
{
String cmd = String("get ");
cmd += getObjName();
cmd += ".picc";
sendCommand(cmd.c_str());
return recvRetNumber(number);
}
bool NexCrop::setPic(uint32_t number)
{
char buf[10] = {0};
String cmd;
utoa(number, buf, 10);
cmd += getObjName();
cmd += ".picc=";
cmd += buf;
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
/**
* @file NexCrop.h
*
* The definition of class NexCrop.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#ifndef __NEXCROP_H__
#define __NEXCROP_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexCrop component.
*/
class NexCrop: public NexTouch
{
public: /* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexCrop(uint8_t pid, uint8_t cid, const char *name);
/**
* Get the number of picture.
*
* @param number - an output parameter to save the number of picture.
*
* @retval true - success.
* @retval false - failed.
*/
bool getPic(uint32_t *number);
/**
* Set the number of picture.
*
* @param number - the number of picture.
*
* @retval true - success.
* @retval false - failed.
*/
bool setPic(uint32_t number);
};
/**
* @}
*/
#endif /* #ifndef __NEXCROP_H__ */
/**
* @file NexDualStateButton.cpp
*
* The implementation of class NexDSButton.
*
* @author huang xianming (email:<xianming.huang@itead.cc>)
* @date 2015/11/11
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#include "NexDualStateButton.h"
NexDSButton::NexDSButton(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
bool NexDSButton::getValue(uint32_t *number)
{
String cmd = String("get ");
cmd += getObjName();
cmd += ".val";
sendCommand(cmd.c_str());
return recvRetNumber(number);
}
bool NexDSButton::setValue(uint32_t number)
{
char buf[10] = {0};
String cmd;
utoa(number, buf, 10);
cmd += getObjName();
cmd += ".val=";
cmd += buf;
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
/**
* @file NexDualStateButton.h
*
* The definition of class NexDSButton.
*
* @author huang xianming (email:<xianming.huang@itead.cc>)
* @date 2015/11/11
*
*
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#ifndef __NEXDSBUTTON_H__
#define __NEXDSBUTTON_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexDSButton component.
*
* Commonly, you want to do something after push and pop it. It is recommanded that only
* call @ref NexTouch::attachPop to satisfy your purpose.
*
* @warning Please do not call @ref NexTouch::attachPush on this component, even though you can.
*/
class NexDSButton: public NexTouch
{
public: /* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexDSButton(uint8_t pid, uint8_t cid, const char *name);
/**
* Get number attribute of component.
*
* @param buffer - buffer storing text returned.
* @param len - length of buffer.
* @return The real length of text returned.
*/
bool getValue(uint32_t *number);
/**
* Set number attribute of component.
*
* @param buffer - number buffer.
* @return true if success, false for failure.
*/
bool setValue(uint32_t number);
};
/**
* @}
*/
#endif /* #ifndef __NEXDSBUTTON_H__ */
/**
* @file NexGauge.cpp
*
* The implementation of class NexGauge.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#include "NexGauge.h"
NexGauge::NexGauge(uint8_t pid, uint8_t cid, const char *name)
:NexObject(pid, cid, name)
{
}
bool NexGauge::getValue(uint32_t *number)
{
String cmd = String("get ");
cmd += getObjName();
cmd += ".val";
sendCommand(cmd.c_str());
return recvRetNumber(number);
}
bool NexGauge::setValue(uint32_t number)
{
char buf[10] = {0};
String cmd;
utoa(number, buf, 10);
cmd += getObjName();
cmd += ".val=";
cmd += buf;
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment