Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
LambdaController.h
- Committer:
- gakuburu
- Date:
- 2016-11-12
- Revision:
- 0:728c138f0486
File content as of revision 0:728c138f0486:
#ifndef LAMBDA_CONTROLLER_H
#define LAMBDA_CONTROLLER_H
#include "mbed.h"
class LambdaController {
public:
LambdaController(PinName tx, PinName rx, PinName hzpin);
uint16_t get_all_switch(void);
bool get_switch(int num);
enum AxisId {
Stick0X, Stick0Y, Stick1X, Stick1Y
};
int get_raw_axis(AxisId id);
double get_axis(AxisId id);
void initialize_axis(void);
void initialize_axis(AxisId id);
enum ErrorFactor {
NoError, NoDataError, TimeoutError, InvalidDataError, SerialBusyError
};
ErrorFactor get_error();
private:
Serial device;
DigitalIn hzjudge;
void data_receive_isr();
int buffer_head;
uint8_t received_data[11];
uint8_t received_buffer[11];
bool is_axis_initialized;
int axis_center[4];
static const double axis_threshold = 0.012;
Timer error_timer;
int error_count;
ErrorFactor error_id;
static const int error_threshold = 5;
static const double timeout_time = 0.5;
};
#endif