To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.spyboticsOpen lugnet.robotics.spybotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Spybotics / 264
263  |  265
Subject: 
Spybot Studies: display an 8-bit value
Newsgroups: 
lugnet.robotics.spybotics
Date: 
Fri, 7 Nov 2003 16:21:11 GMT
Viewed: 
5421 times
  
I feel a little sheepish posting such simple code, but I needed to write this
function anyway, and it's a legitimate illustration of a couple functions, which
is the goal of "Spybot Studies" and this is a run-on sentence.

/*
  led_8bit_display

  A simple macro to use the 3 red, 3 green, and 1 yellow display LEDs plus
  the laser LED to display an 8-bit value as a binary. Useful for debugging.
  From LSB to MSB, the order is red display LEDs, green display LEDs,
  yellow LED, laser LED.

  This study illustrates the use of
      SetLED(LED_MODE_ON, x)
      SetLED(LED_MODE_YELLOW, x)
      SetLIGHT( [LIGHT_ON] | [LIGHT_OFF] )

  Now if I could only pass
  the parameter on the stack to a subroutine, I wouldn't have to
  inline all this code.... :)

  I know I've seen someone else do this already, but I can't find the link.

  -Brian Alano
*/

#include "spy.nqh"

#define SetLEDBinary(x) SetLED(LED_MODE_ON, x); \
                       SetLED(LED_MODE_YELLOW, (x >> 6) & 0x01) ; \
      if ( x & 0x80) { SetLight(LIGHT_ON); } \
                           else { SetLight(LIGHT_OFF); }


task main()
{
     int i;
     for (i=0; i < 256; i++)
     {
SetLEDBinary(i);
Wait(3);
     }

}



Message has 2 Replies:
  Re: Spybot Studies: display an 8-bit value
 
(...) Another very simple thing to do to display this type of "debug" information is to send a message to an RCX, and display the value on the LCD of the RCX. That way, you don't need to mess with decoding the 8 bit binary number. This was not my (...) (21 years ago, 7-Nov-03, to lugnet.robotics.spybotics)
  Re: Spybot Studies: display an 8-bit value
 
(...) Mark Riley did this using MindScript but I don't recall having already seen the equivalent in NQC. (URL) than use a #define macro (speaking of which, I need to fix the syntax highlighting of preprocessor macros to account for multiple lines) I (...) (21 years ago, 7-Nov-03, to lugnet.robotics.spybotics)

4 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR