User Tools

Site Tools


reu:lcd_graphics

LCD Graphics Project

Project Overview

  1. Graphics
    • This program uses graphical elements to show the intensity of light and sound that is received by the leJOS robot's sensors. The program displays the intensity of light as a vertical bar that varies directly with the amount of light that is received, i.e. more intense light denotes a taller bar. The program displays the intensity of sound as a line graph that is constantly being updated as new intensities of sound are received. The program creates a scrolling effect which makes the LCD appear as though it were scrolling to the left as new sound values are gathered and old ones are discarded.
  2. Threads and Synchronization
    • The threading and synchronization are used to determine which display, the line graph or the bar, is to be drawn. Since there is only one LCD screen per NXT Brick and the displays require the entire screen, only one of the two graphs can be shown at any one time. Therefore, utilization of wait and notifyAll allow for the program to decide which display to draw to the screen based on user input.
  3. Listeners
    • The listeners that are used throughout the program are there for user compatibility. If the program were to rely on the code that was given in the library of the leJOS API, the user might have difficulty interacting with the program.

Project Execution

Tasks

  1. Create a robot that can display to the user the intensity of light and sound that it is detecting in its current environment.
  2. Display to the user the intensity of light as a vertical bar with height varying by the intensity of the light. Also display the actual light intensity's numerical value next to the bar.
  3. Display to the user the intensity of sound as a line graph that scrolls to the left smoothly as new values of sound are added.
  4. Allow the user to switch back and forth from the sound intensity's line graph and the light intensity's bar graph at will. This should be done by pressing the TouchSensor.
  5. Use a listener for both the switching from one display to another and the desire to exit the program.

Procedure

  1. First create a bar which has variable height based on the intensity of light in the current environment. This should be done reading the “normalized” value from the LightSensor. Place the bar slightly to the left side of the LCD screen and place the actual numerical value of the light intensity to the right of the bar.
  2. Create a line graph that will plot points according to the intensity of the sound that is occurring within the environment. The points should be plotted closer to the top of the LCD screen as the intensity of sound detected by the SoundSensor increases. The program should then scroll the line graph in much the same way as a seismograph as new sound intensity values are recorded. This should allow for the most recent values to remain plotted on the screen.
  3. Implement a listener for both the switching and the exiting of the program. The command should be clear when the user wishes to do something, i.e. if the user wishes to switch displays, the user must press and release the TouchSensor to switch the displays; merely holding the sensor down will not make the program continuously switch back and forth from one display to another.

Final Remarks

  1. There should be a label located somewhere on the display that tells the user what type of data is being drawn. For example, during the sound intensity line graph, the LCD screen should display something similar to “SOUND INTENSITY”.
  2. After the program draws to the LCD screen, the program should not immediately update the display. The program should give the user some time to read the display. Therefore, the program should wait for a period of time and then update the display again.
  3. When drawing the line graph and/or the bar graph, keep in mind that the dimensions of the LCD screen are 100 x 64 pixels.
  4. Make sure to draw the bar graph as a percentage of the light intensity that is being read by the LightSensor; it is not wise to make the height of the bar the actual normalized value of the light sensor's input.
  5. The usage of a dynamic data structure, such as a linked list, is not necessary for this project. The bar graph has no need to keep track of old values, and the line graph has a maximum number points that can be drawn to the screen at any one time, therefore it should only require a static amount of storage that is necessary to make the line graph animation.
  6. The method isPressed that is provided for the TouchSensor is only true if the TouchSensor is pressed. Therefore, if the user were to hold the sensor down, the program would continue to switch back and forth between the two displays; in other words, if the program only utilized the isPressed method, it is very difficult to switch to a desired display easily. This should be taken care of by the implementation and design of a well made listener. This holds true also the listener for the user to exit the program.
  7. The join method is not necessary for this project. The main thread should exit after starting the other threads. It is not mandatory for the main thread to wait until all of the other threads have finished since the main thread has no need for any data that is held by the other threads.
  8. Create a non-threaded version first then implement threading. This will help in debugging.
reu/lcd_graphics.txt · Last modified: 2009/01/22 15:13 by akhandok