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.
main.cpp@0:5e722fb2f2bc, 2010-12-23 (annotated)
- Committer:
- JLS
- Date:
- Thu Dec 23 14:40:03 2010 +0000
- Revision:
- 0:5e722fb2f2bc
- Child:
- 1:2dcd2355ae5e
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JLS | 0:5e722fb2f2bc | 1 | #include "TFT_4DGL.h" |
JLS | 0:5e722fb2f2bc | 2 | |
JLS | 0:5e722fb2f2bc | 3 | TFT_4DGL lcd(p9,p10,p11); |
JLS | 0:5e722fb2f2bc | 4 | |
JLS | 0:5e722fb2f2bc | 5 | int main() { |
JLS | 0:5e722fb2f2bc | 6 | |
JLS | 0:5e722fb2f2bc | 7 | float x = 0.5; |
JLS | 0:5e722fb2f2bc | 8 | float y = 0.25; |
JLS | 0:5e722fb2f2bc | 9 | float z = 0.125; |
JLS | 0:5e722fb2f2bc | 10 | float oldx = 0; |
JLS | 0:5e722fb2f2bc | 11 | float oldy = 0; |
JLS | 0:5e722fb2f2bc | 12 | float oldz = 0; |
JLS | 0:5e722fb2f2bc | 13 | |
JLS | 0:5e722fb2f2bc | 14 | float dt = 0.02; |
JLS | 0:5e722fb2f2bc | 15 | |
JLS | 0:5e722fb2f2bc | 16 | float alpha = 15.6; |
JLS | 0:5e722fb2f2bc | 17 | float beta = 28.58; |
JLS | 0:5e722fb2f2bc | 18 | float a = -1.14286; |
JLS | 0:5e722fb2f2bc | 19 | float b = -0.714286; |
JLS | 0:5e722fb2f2bc | 20 | float h = 0; |
JLS | 0:5e722fb2f2bc | 21 | |
JLS | 0:5e722fb2f2bc | 22 | int xout = 0; |
JLS | 0:5e722fb2f2bc | 23 | int yout = 0; |
JLS | 0:5e722fb2f2bc | 24 | |
JLS | 0:5e722fb2f2bc | 25 | lcd.baudrate(600000); |
JLS | 0:5e722fb2f2bc | 26 | |
JLS | 0:5e722fb2f2bc | 27 | while (1) { |
JLS | 0:5e722fb2f2bc | 28 | |
JLS | 0:5e722fb2f2bc | 29 | oldx = x; |
JLS | 0:5e722fb2f2bc | 30 | oldy = y; |
JLS | 0:5e722fb2f2bc | 31 | oldz = z; |
JLS | 0:5e722fb2f2bc | 32 | |
JLS | 0:5e722fb2f2bc | 33 | h = (b * x) + (0.5 * (a - b) * (abs(x+1) - abs(x-1))); |
JLS | 0:5e722fb2f2bc | 34 | |
JLS | 0:5e722fb2f2bc | 35 | x = oldx + dt * (alpha * (oldy - oldx - h)); |
JLS | 0:5e722fb2f2bc | 36 | y = oldy + dt * (oldx - oldy + oldz); |
JLS | 0:5e722fb2f2bc | 37 | z = oldz + dt * (-beta * oldy); |
JLS | 0:5e722fb2f2bc | 38 | |
JLS | 0:5e722fb2f2bc | 39 | xout = 160+(60*x); |
JLS | 0:5e722fb2f2bc | 40 | yout = 120+3*(60*y); |
JLS | 0:5e722fb2f2bc | 41 | |
JLS | 0:5e722fb2f2bc | 42 | lcd.pixel(yout,xout,WHITE); |
JLS | 0:5e722fb2f2bc | 43 | |
JLS | 0:5e722fb2f2bc | 44 | } |
JLS | 0:5e722fb2f2bc | 45 | } |