In this assignment you will use inputs from sensors to draw a simple graph in your EnergyView window of your main (large screen) user interface. You will gain practice with taking input from simple sensors,computing the appropriate values, and updating graphics in real time.
In this assignment, you will create an energy view that consists of 2 simple line graphs to replace your surrent static Energy View. We want these graphs to look like they are being updated in real time, but since you have not yet learned how to use "waiting", we will fake it. Each NEW input that comes in will advance the time by 1 unit. Your graph should be divided into 100 "ticks" representing time units. In other words, the x axis of your graphs is TIME. So, for exmaple, if you change the external temperature, you will recompute all your values, plot the new values for both graphs, set the appropriate highlighting (see below) and join the lines. Similarly, any change in the energy use from new sensor values will cause you to replot the lines. This means you need to keep the current state of all your variables as well as a list of all the points in each graph. The values in the line graphs will be driven by input from 3 types of Arduino sensors:
In addition, you will have a button on your window that will "turn on/off" appliances. You will then calculate the energy values used as follows.
|
![]() |
HintsRemember to keep a list of all the points in each line graph so that your paintComponent() always draws a list of points. ONLY draw the most recent 100 points. Get this working as a standalone application first and then attach to your main energy journal if it is easier. This means asfter you get it working you MUST do the computation in the Model and NOT in the UI. |
|
This assignment will probably be a bit easier for most people than the last one.
To turn in the assignment, please follow the same process as last time
If you do any extra credit work, be sure to let us know about it in the Design Document so that we don't miss it!!
Please take care to remove any platform dependencies, such as hardcoded Windows path names or dependence on a particular look-and-feel that may not exist on all platforms. Also, if you use any images in your application, please make sure that you include these in your ZIP file and that your code will refer to them and load them properly when from from inside the directory that's created when I unZIP your code.
Grading for this assignment, and future assignments, will roughly follow this breakdown: