C language. A file, display.c handles all display to the LED
array. It will need a global variable with type *pi_framebuffer_t.
(in C, "global" variables are scoped only to the file in which they
are defined unless other actions are taken). Should have at least
the following functions:
void openDisplay(void): allocate the Pi Framebuffer device and
store in a "global" variable for later use. This function should
only need to be called one time when the program runs.
void closeDisplay(void): deallocate the Pi Framebuffer device (if
it exists) and set the storage variable to NULL. Be sure this does
the right thing if called before openDisplay()!
void displayLetter(char letter, int xOffset, int yOffset) : draws
the provided letter on the LED array oriented so that "down" is
towards the joystick, but shifted to the right by xOffset and down
by yOffset. Note: the only letters you need to be able to draw are
the capital initials of all partners in your group (you should be
able to draw upon the "monogramming" assignment). Don't forget that
if all letters would be the same, substitute a '3' for one of
them.
void clearDisplay(void): clears the display
#include "scroll.h"
#include <stddef.h>
#include <stdio.h>
#include "sense.h"
#define BLACK 0x0000
#define WHITE 0xFFFF
pi_framebuffer_t *fb = NULL;
void openDisplay(void)
{
if(fb==NULL)
{
fb=getFrameBuffer();
}
}
void closeDisplay(void)
{
if(fb)
{
clearFrameBuffer(fb,BLACK);
freeFrameBuffer(fb);
fb=NULL;
}
}
void displayLetter(char letter, int xOffset, int yOffset)
{
if(fb == NULL)
{
fprintf(stderr,"Tried to draw
(%d,%d) to a non-existent frame buffer!\n",xOffset,yOffset);
return;
}
sense_fb_bitmap_t *bm=fb->bitmap;
clearFrameBuffer(fb,BLACK);
xOffset=(xOffset%8+8)%8;
yOffset=(yOffset%8+8)%8;
if(letter == 'Y')
{
bm->pixel[(1+yOffset)%8][(1+xOffset)%8]=WHITE;
bm->pixel[(1+yOffset)%8][(2+xOffset)%8]=WHITE;
bm->pixel[(1+yOffset)%8][(3+xOffset)%8]=WHITE;
bm->pixel[(2+yOffset)%8][(4+xOffset)%8]=WHITE;
bm->pixel[(3+yOffset)%8][(5+xOffset)%8]=WHITE;
bm->pixel[(3+yOffset)%8][(6+xOffset)%8]=WHITE;
bm->pixel[(3+yOffset)%8][(7+xOffset)%8]=WHITE;
bm->pixel[(6+yOffset)%8][(1+xOffset)%8]=WHITE;
bm->pixel[(6+yOffset)%8][(2+xOffset)%8]=WHITE;
bm->pixel[(6+yOffset)%8][(3+xOffset)%8]=WHITE;
bm->pixel[(5+yOffset)%8][(4+xOffset)%8]=WHITE;
bm->pixel[(4+yOffset)%8][(5+xOffset)%8]=WHITE;
bm->pixel[(4+yOffset)%8][(6+xOffset)%8]=WHITE;
bm->pixel[(4+yOffset)%8][(7+xOffset)%8]=WHITE;
}
else if(letter == 'N')
{
bm->pixel[(1+yOffset)%8][(1+xOffset)%8]=WHITE;
bm->pixel[(1+yOffset)%8][(2+xOffset)%8]=WHITE;
bm->pixel[(1+yOffset)%8][(3+xOffset)%8]=WHITE;
bm->pixel[(1+yOffset)%8][(4+xOffset)%8]=WHITE;
bm->pixel[(1+yOffset)%8][(5+xOffset)%8]=WHITE;
bm->pixel[(1+yOffset)%8][(6+xOffset)%8]=WHITE;
bm->pixel[(1+yOffset)%8][(7+xOffset)%8]=WHITE;
bm->pixel[(6+yOffset)%8][(1+xOffset)%8]=WHITE;
bm->pixel[(6+yOffset)%8][(2+xOffset)%8]=WHITE;
bm->pixel[(6+yOffset)%8][(3+xOffset)%8]=WHITE;
bm->pixel[(6+yOffset)%8][(4+xOffset)%8]=WHITE;
bm->pixel[(6+yOffset)%8][(5+xOffset)%8]=WHITE;
bm->pixel[(6+yOffset)%8][(6+xOffset)%8]=WHITE;
bm->pixel[(6+yOffset)%8][(7+xOffset)%8]=WHITE;
bm->pixel[(5+yOffset)%8][(2+xOffset)%8]=WHITE;
bm->pixel[(5+yOffset)%8][(3+xOffset)%8]=WHITE;
bm->pixel[(4+yOffset)%8][(3+xOffset)%8]=WHITE;
bm->pixel[(4+yOffset)%8][(4+xOffset)%8]=WHITE;
bm->pixel[(3+yOffset)%8][(4+xOffset)%8]=WHITE;
bm->pixel[(3+yOffset)%8][(5+xOffset)%8]=WHITE;
bm->pixel[(2+yOffset)%8][(5+xOffset)%8]=WHITE;
bm->pixel[(2+yOffset)%8][(6+xOffset)%8]=WHITE;
}
}
void clearDisplay(void)
{
if(fb)
{
clearFrameBuffer(fb,BLACK);
}
}
C language. A file, display.c handles all display to the LED array. It will need a...
Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions. • void getScore() should ask the user for a test score, store it in the reference parameter variable, and validate it. This function should be called by the main once for each of the five scores to be entered. •...
c++ program8. Array/File Functions Write a function named arrayToFile. The function should accept three arguments: the name of a file, a pointer to an int array, and the size of the array. The function should open the specified file in binary mode, write the contents of the array to the file, and then close the file. Write another function named fileToArray. This function should accept three argu- ments: the name of a file, a pointer to an int array, and the size...
u also need to store the letters' ASCII number in the freq array 4. [8] Write a C function with prototype · void letter_freq(const char word[], int freq []); This function computes the number of appearances of each letter in the string word and stores them in array freq of size 26. The letters are the 26 letters of the Latin alphabet whose ASCII values are in the range 97-122 for the lower case letters, and in the range 65-90...
Files given in this assignment (right-click on the file to download) Assignment7.cpp (need to complete) Student.h (Given. Just use it, don't change it!) Student.cpp (Partially filled, need to complete) 1. Assignment description In this assignment, you will write a simple class roster management system for ASU CSE100. Step #1: First, you will need to finish the design of class Student. See the following UML diagram for Student class, the relevant header file (class declaration) is given to you as Student.h,...
c++ please read all question edit the program to test different random sizes of the array and give me the time in a file will be like random size of the array and next to it the time it took for each size Im trying to do time analysis for Quick sort but i keep getting time = 0 also i want edit the program to test different random sizes of the array and give me the time in a...
Write a program in C language that reads scores and id numbers from a file, finds the average score, and assigns each student a grade based on the following rules: Each score > average + 20 gets an A Each score between average + 10 and average + 20 gets a B Each score between average - 10 and average + 10 gets a C Each score between average - 20 and average - 10 gets a D Each score...
I am struggling with a program in C++. it involves using a struct and a class to create meal arrays from a user. I've written my main okay. but the functions in the class are giving me issues with constructors deconstructors. Instructions A restaurant in the Milky way galaxy called “Green Alien” has several meals available on their electronic menu. For each food item in each meal, the menu lists the calories per gram and the number of grams per...
C++ I need a program that will read a list of names from a data file and store them in an array. You will then sort the array by last name using a quicksort, and display the results, one name per line.Each line has a first name and a last name.The file has 40 names in it right now, but the array should be able to accommodate up to 50 names.txt***************************************************** Barbara Wright Ian Chesterton Steven Taylor Sara Kingdom Dodo...
There are a number of changes that we need to make: 1) We need to take the board size (width and height) as command line parameters. If these are not specified, we should print out a message informing the user how to call the program. 2) We need to initialize a game board. Allocate memory, decide if each square has bombs, and count the squares surrounding that have bombs. 3) We need to free the game board. Because we need...