PropWare
C++ objects and CMake build system for Parallax Propeller
Home
Download
Getting Started
Documentation
Reference
About
Related Links
Namespace List
Class List
File List
Examples
Build System
File List
File Members
propsideworkspace
Learn
Examples
Badge
01 Display
10 Plot Sine Cosine.c
1
/*
2
Plot Sine Cosine (1).c
3
Plot y = sin(2theta) and y = cos(2theta) together.
4
*/
5
6
#include "simpletools.h"
// Include simpletools library
7
#include "
badgetools.h
"
// Include badgetools library
8
9
int
x, y;
// Integer X and Y for pixels
10
float
brad, theta;
// Floating point for sin & cos
11
12
void
main
()
// Main function
13
{
14
badge_setup
();
// Call badge setup
15
line
(0, 0, 0, 64, 1);
// Line along left of screen
16
line
(0, 32, 128, 32, 1);
// Horizontal line across center
17
18
brad = 2*PI/128;
// Brad value (binary radian)
19
20
for
(x = 0; x < 128; x++)
// Count 0 to 127
21
{
22
theta = (float) x * brad;
// Theta in binary radians
23
// Calculate with floating point, then
24
// convert to int for plotting as point.
25
y = 32 - (int)(24.0 * sin(2.0 * theta));
// y = sin(2theta)
26
point
(x, y, 1);
// Plot white point
27
y = 32 - (int)(24.0 * cos(2.0 * theta));
// y = cos(2theta)
28
point
(x, y, 1);
// Plot white point
29
}
30
}
point
void point(int x, int y, int color)
Plot a point on the oLED screen.
main
int main(void)
Definition:
GraphicsTest.c:20
badge_setup
int badge_setup(void)
Set up all available badge drivers. Call this function at the start of any given program to allow acc...
Definition:
badgealpha.c:29
badgetools.h
This library provides convenient functions for a variety of Parallax eBadge operations.
line
void line(int x0, int y0, int x1, int y1, int c)
Plot a line on the oLED screen.
Generated on Sat Aug 27 2016 00:58:03 for PropWare by
1.8.12