Our new official repo is on github
LCD Smartie version 5.6 is released!
Download it now: https://github.com/LCD-Smartie/LCDSmartie/releases

2 bars source

Discussing issues that occur during plugin development.

Moderators: _X7JAY7X_, caesar, IFR, mattcro, limbo

Post Reply
elesquiador
Plugin Author
Posts: 18
Joined: February 9th, 2007, 10:47 pm

2 bars source

Post by elesquiador »

2 Bars c++ source, in case anyone finds it useful. I'm a relatively new programmer, so if anyone has suggestions to make this run more efficiently, they are appreciated.

Functions 1-8 just call another function using the appropriate custom character number. Ex.:

Code: Select all

extern "C" DLLEXPORT  char *
__stdcall  function1(char *param1, char *param2)
{
 return bar(1, param1, param2);
}
The function that does the work:

Code: Select all

char* bar (int no, char* param1, char* param2)
{
  //param1 is the value of bar 1, param2 is bar2
  double vala = atof (param1);
  double valb = atof (param2);
  //start with a blank custom character
  int graph[] = {0,0,0,0,0,0,0,0};
  //and also define the $Chr numbers
  static const char* const chrs[] = {"176", "158", "131", "132", "133", "134", "135", "136"};
  //define the breakpoints for each pixel
  static const double breaks[] = {88.89, 77.78, 66.67, 55.56, 44.44, 33.33, 22.22, 11.11};

  //define the custom character
  for (int i = 0; i<8; i++)
  {
   if (vala >= breaks[i]) graph[i] += 24;
   if (valb >= breaks[i]) graph[i] += 3;
  }

  //build the string to return
  std::stringstream ret;
  ret << "$CustomChar(" << no << ",";
  for (int i = 0; i < 7; i++)
      ret << graph[i] << ", ";
  ret << graph[7] << ")$Chr(" << chrs[no-1] << ")";
  static char out[100];
  strcpy(out, ret.str().c_str());
  return(out);
}
Also, a question for visual studio people (I have coded only under linux prior to this). I can build the dll just fine when I am set to debug and it works in smartie, but if I change to the release build, the dll produces garbage on the screen when called by smartie (although the file is much smaller). What is the difference between the release and debug builds and why won't the release build work?

limbo
Plugin Author
Posts: 1604
Joined: February 13th, 2005, 7:38 pm
Location: Athens - Greece
Contact:

Re: 2 bars source

Post by limbo »

elesquiador wrote: Also, a question for visual studio people (I have coded only under linux prior to this). I can build the dll just fine when I am set to debug and it works in smartie, but if I change to the release build, the dll produces garbage on the screen when called by smartie (although the file is much smaller). What is the difference between the release and debug builds and why won't the release build work?
Are U using the rebuild command of VS? If not try it.
Maybe the settings of your project limit the release build. Check carefully these settings.
I always use the release dll with no problem at all (VS.NET 2003 and 2005)

Post Reply