A metatable can be defined like
local t = setmetatable({}, {
__tostring = function() return 'custom tostring behavior!' end
})
Here are the metamethods that you can define, and their behavior
/****************************************************************************** | |
* MSP430 ADC10 Example for the G2231 | |
* | |
* Description: This code provides an example for using the 10 bit ADC in the | |
* MSP430G2231. The code requires either a terminal program or | |
* the application provided on the blog mentioned below. | |
* depending on which ascii character is sent to the device, | |
* either VCC, the temperature sensor, or an external pin will | |
* be measured once and the results sent to the computer. | |
* |
#include "msp430G2452.h" | |
#define FAN_CNT (3) | |
#define PWM_FREQ (32) | |
#define PWM_RESS (128) | |
// Port 1 | |
#define LED1 (1<<0) | |
#define TMP_RX (1<<1) | |
static const int TACH[] = { (1<<3), (1<<4), (1<<5) }; |