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.
Dependencies: mbed mbed-rtos MotionSensor EthernetInterface
Diff: Protocol/receiver.h
- Revision:
- 14:e8cd237c8639
- Parent:
- 13:f7a7fe9b5c00
- Child:
- 15:69d9e85382de
--- a/Protocol/receiver.h Sat Apr 30 21:28:27 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* -Copyright 2016 Erik Perillo <erik.perillo@gmail.com> - -This file is part of piranha-ptc. - -This 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 3 of the License, or -(at your option) any later version. - -This is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this. If not, see <http://www.gnu.org/licenses/>. -*/ - - -#ifndef __PIRANHA_RCV_PROTOCOL_H__ -#define __PIRANHA_RCV_PROTOCOL_H__ - -#include "protocol.h" -#include "mbed.h" - - -/** - Reads serial and converts a string of (one or two) bytes into an unsigned int. - Least-significant bytes must come first. - Assumes big-endian representation of numbers on architecture. -*/ -uint16_t read(Serial& serial); - -/** - Converts unsigned int into float following unit-normalization rules. -*/ -float un_scale(uint16_t value, float min, float max); - -/** - Applies un_scale to value read on serial. -*/ -float get_param(Serial& serial, float min, float max); - -/** - Gets all 4 pid parameters from serial stream. -*/ -void get_pid_params(Serial& serial, float* kp, float* ki, float* kd, float* n); - -//macros just to make life easier -#define get_pid_param(serial) get_param(serial, PID_PARAMS_MIN, PID_PARAMS_MAX) -#define get_gnd_speed(serial) get_param(serial, GND_SPEED_MIN, GND_SPEED_MAX) -#define get_ang_ref(serial) get_param(serial, ANG_REF_MIN, ANG_REF_MAX) - -#endif -