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 / 266
265  |  267
Subject: 
Re: Spybot Studies: display an 8-bit value
Newsgroups: 
lugnet.robotics.spybotics
Date: 
Fri, 7 Nov 2003 19:45:03 GMT
Viewed: 
5592 times
  
In lugnet.robotics.spybotics, Brian B. Alano wrote:
  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.


Mark Riley did this using MindScript but I don't recall having already seen the
equivalent in NQC.

http://news.lugnet.com/robotics/spybotics/?n=56

Rather than use a #define macro (speaking of which, I need to fix the syntax
highlighting of preprocessor macros to account for multiple lines) I would use a
function:

void SetLEDBinary2(const int &x)
{
  SetLED(LED_MODE_ON, x);
  SetLED(LED_MODE_YELLOW, (x >> 6) & 0x01);
  // use SetLED rather than SetLight so that you can pass a variable
  SetLED(LED_MODE_VLL, x & 0x80);
}

In NQC the resulting compiled code will be identical to what you get when using
a preprocessor macro (but it looks nicer, imho).

John Hansen



Message has 1 Reply:
  Re: Spybot Studies: display an 8-bit value
 
(...) In case anyone was wondering (yeah, sure :-), this line in my original post: lediDisplay = (x & 0x17) ((x & 8) * 4) ((x & 32) / 4) rearranges the bits so that the lower 6 bits can easily be read left to right (while looking at the bot from the (...) (21 years ago, 7-Nov-03, to lugnet.robotics.spybotics, FTX)

Message is in Reply To:
  Spybot Studies: display an 8-bit value
 
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 (...) (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

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

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