This project will enable remote control of a motorised turntable via a WiFi enabled TCP link using ACKme's (http://ack.me/) Wi-Fi enablement platform

Dependencies:   mbed

Committer:
Stathisn
Date:
Wed Aug 27 12:28:48 2014 +0000
Revision:
2:a73037a7d85d
Parent:
1:7b420a2ea7db
Cleaned up control code and created an object to handle its operation; Integrated feedback over serial for debugging purposes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Stathisn 1:7b420a2ea7db 1 /**
Stathisn 1:7b420a2ea7db 2 * ACKme WiConnect Host Library is licensed under the BSD licence:
Stathisn 1:7b420a2ea7db 3 *
Stathisn 1:7b420a2ea7db 4 * Copyright (c)2014 ACKme Networks.
Stathisn 1:7b420a2ea7db 5 * All rights reserved.
Stathisn 1:7b420a2ea7db 6 *
Stathisn 1:7b420a2ea7db 7 * Redistribution and use in source and binary forms, with or without modification,
Stathisn 1:7b420a2ea7db 8 * are permitted provided that the following conditions are met:
Stathisn 1:7b420a2ea7db 9 *
Stathisn 1:7b420a2ea7db 10 * 1. Redistributions of source code must retain the above copyright notice,
Stathisn 1:7b420a2ea7db 11 * this list of conditions and the following disclaimer.
Stathisn 1:7b420a2ea7db 12 * 2. Redistributions in binary form must reproduce the above copyright notice,
Stathisn 1:7b420a2ea7db 13 * this list of conditions and the following disclaimer in the documentation
Stathisn 1:7b420a2ea7db 14 * and/or other materials provided with the distribution.
Stathisn 1:7b420a2ea7db 15 * 3. The name of the author may not be used to endorse or promote products
Stathisn 1:7b420a2ea7db 16 * derived from this software without specific prior written permission.
Stathisn 1:7b420a2ea7db 17 *
Stathisn 1:7b420a2ea7db 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED
Stathisn 1:7b420a2ea7db 19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
Stathisn 1:7b420a2ea7db 20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
Stathisn 1:7b420a2ea7db 21 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
Stathisn 1:7b420a2ea7db 22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
Stathisn 1:7b420a2ea7db 23 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Stathisn 1:7b420a2ea7db 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
Stathisn 1:7b420a2ea7db 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
Stathisn 1:7b420a2ea7db 26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
Stathisn 1:7b420a2ea7db 27 * OF SUCH DAMAGE.
Stathisn 1:7b420a2ea7db 28 */
Stathisn 1:7b420a2ea7db 29 #pragma once
Stathisn 1:7b420a2ea7db 30
Stathisn 1:7b420a2ea7db 31 #include <stdarg.h>
Stathisn 1:7b420a2ea7db 32
Stathisn 1:7b420a2ea7db 33 #include "mbed.h"
Stathisn 1:7b420a2ea7db 34
Stathisn 1:7b420a2ea7db 35
Stathisn 1:7b420a2ea7db 36
Stathisn 1:7b420a2ea7db 37
Stathisn 1:7b420a2ea7db 38 class ConsoleSerial : public Serial
Stathisn 1:7b420a2ea7db 39 {
Stathisn 1:7b420a2ea7db 40 public:
Stathisn 1:7b420a2ea7db 41
Stathisn 1:7b420a2ea7db 42 ConsoleSerial(PinName tx, PinName rx) : Serial(tx, rx)
Stathisn 1:7b420a2ea7db 43 {
Stathisn 1:7b420a2ea7db 44
Stathisn 1:7b420a2ea7db 45 }
Stathisn 1:7b420a2ea7db 46
Stathisn 1:7b420a2ea7db 47 void setBaud(int baud)
Stathisn 1:7b420a2ea7db 48 {
Stathisn 1:7b420a2ea7db 49 this->baud(baud);
Stathisn 1:7b420a2ea7db 50 }
Stathisn 1:7b420a2ea7db 51
Stathisn 1:7b420a2ea7db 52 using FileHandle::read;
Stathisn 1:7b420a2ea7db 53 using FileHandle::write;
Stathisn 1:7b420a2ea7db 54 int read()
Stathisn 1:7b420a2ea7db 55 {
Stathisn 1:7b420a2ea7db 56 return getc();
Stathisn 1:7b420a2ea7db 57 }
Stathisn 1:7b420a2ea7db 58
Stathisn 1:7b420a2ea7db 59 void write(int c)
Stathisn 1:7b420a2ea7db 60 {
Stathisn 1:7b420a2ea7db 61 putc(c);
Stathisn 1:7b420a2ea7db 62 }
Stathisn 1:7b420a2ea7db 63
Stathisn 1:7b420a2ea7db 64 void write(const char *s)
Stathisn 1:7b420a2ea7db 65 {
Stathisn 1:7b420a2ea7db 66 puts(s);
Stathisn 1:7b420a2ea7db 67 }
Stathisn 1:7b420a2ea7db 68
Stathisn 1:7b420a2ea7db 69 void write(char *s)
Stathisn 1:7b420a2ea7db 70 {
Stathisn 1:7b420a2ea7db 71 puts(s);
Stathisn 1:7b420a2ea7db 72 }
Stathisn 1:7b420a2ea7db 73
Stathisn 1:7b420a2ea7db 74 void write(const void *data, int size)
Stathisn 1:7b420a2ea7db 75 {
Stathisn 1:7b420a2ea7db 76 Serial::write(data, size);
Stathisn 1:7b420a2ea7db 77 }
Stathisn 1:7b420a2ea7db 78
Stathisn 1:7b420a2ea7db 79 void printf(const char *fmt, ...)
Stathisn 1:7b420a2ea7db 80 {
Stathisn 1:7b420a2ea7db 81 va_list va;
Stathisn 1:7b420a2ea7db 82 va_start(va, fmt);
Stathisn 1:7b420a2ea7db 83 vprintf(fmt, va);
Stathisn 1:7b420a2ea7db 84 va_end(va);
Stathisn 1:7b420a2ea7db 85 }
Stathisn 1:7b420a2ea7db 86
Stathisn 1:7b420a2ea7db 87 void vprintf(const char *fmt, va_list va)
Stathisn 1:7b420a2ea7db 88 {
Stathisn 1:7b420a2ea7db 89 char buf[512];
Stathisn 1:7b420a2ea7db 90 vsnprintf(buf, sizeof(buf), fmt, va);
Stathisn 1:7b420a2ea7db 91 write(buf);
Stathisn 1:7b420a2ea7db 92 }
Stathisn 1:7b420a2ea7db 93
Stathisn 1:7b420a2ea7db 94 };