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.
Diff: LambdaController.h
- Revision:
- 0:728c138f0486
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LambdaController.h Sat Nov 12 03:55:50 2016 +0000
@@ -0,0 +1,45 @@
+#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
\ No newline at end of file