The output at the way bottom, there are a bunch of outputs I need them in color and blinking. When it says ON the color should be yellow and When it is OFF color should be white. When it says blinking it should be blinking. Please don't tell me what to do, people told me i tried it did not work, i need someone else to do it for me.
#include <stdio.h>
#include <conio.h>
#include <iostream>
#include <windows.h>
usingnamespace std;
/* prototype (function typedef) for DLL function Oup32fp: */
typedefvoid (_stdcall *oupfuncPtr)(short portaddr, short datum);
#define PPORT_BASE 0x378 // identify port address
// After successful initialization, this variable will contain function pointer.
oupfuncPtr oup32fp;
// Wrapper function for the function pointer - call these functions to perform I/O.
void Out32 (short portaddr, short datum)
{
(oup32fp)(portaddr,datum);
}
HINSTANCE hLib;
int initialize()
{
/* Load the library */
hLib = LoadLibrary("inpout32.dll");
if (hLib == NULL) {
fprintf(stderr,"LoadLibrary Failed.\n");
getch();
return -1;
}
/* get the address of the function */
oup32fp = (oupfuncPtr) GetProcAddress(hLib, "Out32");
if (oup32fp == NULL) {
fprintf(stderr,"GetProcAddress for Oup32 Failed.\n");
getch();
return -1;
}
return 0;
}
// ---------------- DO NOT CHANGE ANY OF THE ABOVE CODE --------------------------
int main()
{
short value; // smaller integer type for port data
int port = PPORT_BASE; // memory address for parallel port
initialize(); // call function to set up port for output
for (int counter = 1; counter <= 5; counter ++)
{
Out32(port,9);// Turn North/South GREEN & Hold WEST/EAST RED
cout << "---North & South = ON East & West = OFF---\n";
Sleep(3000);// Holds Green Light for 3 sec
Out32(port,4);// WEST/EAST RED and NORTH/SOUTH YELLOW
cout << "---North & South = BLINKING East & West = OFF---\n";
Sleep(1000);//Holds YELLOW NORTH/SOUTH
Out32(port,3); // Turn all light RED
cout << "---North & South = OFF East & West = OFF---\n";
Sleep(500); // Hold RED half sec
Out32(port,34);// Turn EAST/ WESTGREEN GREEB AND NORTH/SOUTH RED
cout << "---North & South = OFF East & West = ON---\n";
Sleep(3000);// Holds Green Light for 3 sec
Out32(port,18);// Turns all lights RED and EAST/WEST YELLOW
cout << "---North & South = OFF East & West = BLINKING---\n";
Sleep(2000);//Holds YELLOW EAST/WEST
Out32(port,3); // Turn all light RED
cout << "---North & South = OFF East & West = OFF---\n";
cout << "" << endl;
cout << "Times ran = " << counter << endl;
Sleep(500); // Hold RED half sec
}
FreeLibrary(hLib);
cout << endl;
system("PAUSE");
return(0);
}
Out 32 is an output function. In this case I programmed a cross walk to turn on and off in a certain amount of time. This is how traffic lights and cross walks etc are programmed. I just need to know how to do da color and blinking!!!
What are the parameters you're passing it do? What is the difference between Out32(port,34); and Out32(port,18);?
If you want to change the behavior of the output (ie: change color, have it blink) then you need to understand how this function works and how to use it. If you don't provide us with details/documentation about that function there is nothing we can do to help.
It does not matter about ports. In the program i just have to replicate it to show what is happening. the out 32 is all good, but i just need to change the color of the cout.
Like here
Out32(port,9);// Turn North/South GREEN & Hold WEST/EAST RED
cout << "---North & South = ON East & West = OFF---\n";
Sleep(3000);// Holds Green Light for 3 sec
I need to change ON in to yellow and OFF can stay white. If it blinking it should be obviously blinking.
and the ports are where the signal is going to. when i connect to a circuit, there are differant lights to be turned on at differant times, so you need differant ports
For the blinking, you could even use SetConsoleTextAttribute to set the colour of the section to black on black, and then back to whatever colours you want. You'll probably want to split up the text, though: That way you can make it easier to get the end positions of the text (through strlen or something).