Jump to content

LCD rendering state of pots (via AIN)


jwillans
 Share

Recommended Posts

I would like to render the open state of pots connected via AIN using LCD displays connected to the core module.  Ideally I would like to display this using a bar chart, less ideal would be a numeric rendering (pot 1: 75%).  Is this something that has been done before?

James

Link to comment
Share on other sites

AudioCommander - Thanks, that project looks interesting although I would prefer to use an LCD display.  Two displays would be enough, but I could get away with one.  There will be a single core, with four pots connected via a single AIN, the application simply needs to display the state of the pots on the LCD display(s) and send midi events as the state changes.  How would I go about writing/modifying an application to this?  Do you recommend using the midibox64 application code as a basis for this?

Thanks,

James

Link to comment
Share on other sites

Hi James,

midibox64 is written in ASM, which I don't know enough to say anything about  :-\

However, you could checkout the download section and see if there's an existing C-application that suits your needs. Here's a sample code from TK how to use special chars in C:

http://www.ucapps.de/mios_c_lcd_schars.html

Hope this helps as a starting hint (if you decide to go for mb64 it might help to ask in the ASM or mb64 section, I'm sure this could be done if you're not afraid of ASM ;) )

In theory, a levelchar is nothing else than a number, so regarding the resolution you can show 8 different levels:

0..127 in 8 steps => (value >> 4) => 127 = 7, 64 = 4 ...

Cheers,

Michael

Link to comment
Share on other sites

James,

I'm pretty sure the last thing I was messing with on a box at my Aunt's house was an 8 channel pot app that put the values up on a 2x40 display along with the pot numbers (4 pots per row). It may have had one of the scaling routines in it too, but I'm not sure. It also spits out the 7 bit MIDI values.

It's probably a mess "structure-wise", but you're welcome to it and anything I can remember about it, if you want it. I think it started from the C skeleton.

George

Link to comment
Share on other sites

A further quesions - are "block" characters considered special characters, or are these available as standard?  If they are standard, how do I get them?  I am wanting to do the bars, measuring the pots, horizontally.  I would use blocks + special characters for the leading edge where a block is incomplete.

James

Link to comment
Share on other sites

Here's a sample code from TK how to use special chars in C:

http://www.ucapps.de/mios_c_lcd_schars.html

(...)

In theory, a levelchar is nothing else than a number, so regarding the resolution you can show 8 different levels:

0..127 in 8 steps => (value >> 4) => 127 = 7, 64 = 4 ...

all other ready available characters can be found in the datasheet of your LCD.

Link to comment
Share on other sites

James & David,

Sorry it took me a bit. I came in with a headache last night and just went to sleep. :-\

I grabbed that skeleton, which appears to be the same app I've been seeing on the box every night. It looks like in that one, the "main" is the only changed file, so I'll just paste it into a block here if that's OK. That way someone else can also point out all the crap that's wrong with it and help us both (3 actually). ;D

Warnings-

** I don't know what the hell I'm doing

* I'll go through a whole night of tossing lines or functions in different places to see the result, so there's often stuff in there that serves no practical purpose (for others)

* Some things may be pasted from TK's apps and I'll occasionally change them to suit my needs. I skimmed over the comments and I think they still match up. (mine often have cusswords in them)

* I DON'T know what the hell I'm doing

Two things that appear to also be in there-

* A pin status check which triggers that "lightloop" sequence which I was using as a fancy "indicator"

* Incoming MIDI events which match the pot events also appear to be saved into another array (potsin) for some reason. I'm not sure what I was doing with that group. I keep a whole folder of skeleton mods, so if I can find anything else I'll post.

Lastly-

* The screen draw (or just the pot values part) is probably sort of redundant. It gets called on init, then gets called again on AIN changes. Ideally, it probably should be somewhere else and maybe only draw the changed area, but it didn't matter much on this. Thorsten's apps obviously do it correctly, for a good reference. I think he's usually got a "display update needed" variable which gets checked at more convenient intervals.

Hope there's at least something in this mess that could maybe point you in the right direction. :) Most of the C stuff I was messing with was for a small controller I built which has some unique needs "app-wise". I've been planning to get some help here on the structure of it and will ask in the C forum when the time comes, but I was trying to get some of the individual routines running first anyway. A layout drawing is toward the bottom of this thread:  http://www.midibox.org/forum/index.php?topic=8294.0

BTW- In an attempt to punish myself for killing my hard drive, I've bounced back to some assembler I was playing with on another box <grin>. I also just got a beta build of something thrown at me unexpectedly, which I'll need to be spending time with, but I'm hoping to get back to that C stuff next week. Maybe we can arrive at some useful functions which haven't been done yet and could be pasted as "building blocks" into other's skeletons.

Take Care (and sorry for the forthcoming mess),

George

This was on a box with 8 pots (mux'd), 32 LEDs, 24 buttons, and a 40x2 LCD

/*
 * MIOS SDCC Wrapper
 *
 * ==========================================================================
 *
 *  Copyright (C) <year>  <name> (<email>)
 *  Licensed for personal non-commercial use only.
 *  All other rights reserved.
 * 
 * ==========================================================================
 */

#include "cmios.h"
#include "pic18f452.h"

unsigned char pots[8];
unsigned char potsin[8];

///////////////////Lights////////////////////////////////////////////////////

void lightloop(void) __wparam

	  {	unsigned char count;

	  		for (count = 0 ; count<=0x1F ; count++)

	    MIOS_DOUT_PinSet1(count),
        MIOS_Delay(60),
        MIOS_DOUT_PinSet0(count),
        MIOS_Delay(20);
        }
///////////////////////////////////////////////////////////////////////////////

void showem(void) __wparam
{
	int i,j,t;

	for(i=0,j=6,t=4 ; i<=3 ; i++,j=j+10,t++)
	{
       MIOS_LCD_CursorSet(j);
       MIOS_LCD_PrintBCD3(pots[i]);
       MIOS_LCD_CursorSet(j+64);
       MIOS_LCD_PrintBCD3(pots[t]);

   }
}
/////////////////////////////////////////////////////////////////////////////
void potscan(void) __wparam
{
			int k;

	for(k=0 ; k<=7 ; k++)
	   pots[k] = MIOS_AIN_Pin7bitGet(k);
}
        
        
        
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS after startup to initialize the 
// application
/////////////////////////////////////////////////////////////////////////////
void Init(void) __wparam
{
  MIOS_AIN_NumberSet(8);
  MIOS_AIN_Muxed();
  MIOS_AIN_DeadbandSet(7);	

  MIOS_SRIO_UpdateFrqSet(1); // ms
  MIOS_SRIO_NumberSet(4);
  MIOS_SRIO_DebounceSet(10);
  lightloop();
  potscan();
}

/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS in the mainloop when nothing else is to do
/////////////////////////////////////////////////////////////////////////////
void Tick(void) __wparam
{
}

/////////////////////////////////////////////////////////////////////////////
// This function is periodically called by MIOS. The frequency has to be
// initialized with MIOS_Timer_Set
/////////////////////////////////////////////////////////////////////////////
void Timer(void) __wparam
{
}

/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when the display content should be 
// initialized. Thats the case during startup and after a temporary message
// has been printed on the screen
/////////////////////////////////////////////////////////////////////////////
void DISPLAY_Init(void) __wparam
{
  MIOS_LCD_Clear();
  MIOS_LCD_CursorSet(0x00);
  MIOS_LCD_PrintCString(" Val-      Val-      Val-      Val-");
  MIOS_LCD_CursorSet(0x40);
  MIOS_LCD_PrintCString(" Val-      Val-      Val-      Val-");
  showem();
  }

/////////////////////////////////////////////////////////////////////////////
//  This function is called in the mainloop when no temporary message is shown
//  on screen. Print the realtime messages here
/////////////////////////////////////////////////////////////////////////////
void DISPLAY_Tick(void) __wparam
{
}

/////////////////////////////////////////////////////////////////////////////
//  This function is called by MIOS when a complete MIDI event has been received
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyReceivedEvnt(unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam
{
if(evnt1 == 0x07 && evnt0 >= 0xB0 && evnt0 <= 0xB7) {      //checks for vol message on chans 1-8

	potsin[(evnt0 ^ 0xB0)]=evnt2;
  }

}

/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a MIDI event has been received
// which has been specified in the MIOS_MPROC_EVENT_TABLE
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyFoundEvent(unsigned entry, unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam
{
}

/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a MIDI event has not been completly
// received within 2 seconds
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyTimeout(void) __wparam
{
}

/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a MIDI byte has been received
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyReceivedByte(unsigned char byte) __wparam
{
}

/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS before the shift register are loaded
/////////////////////////////////////////////////////////////////////////////
void SR_Service_Prepare(void) __wparam
{
}

/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS after the shift register have been loaded
/////////////////////////////////////////////////////////////////////////////
void SR_Service_Finish(void) __wparam
{
}

/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when an button has been toggled
// pin_value is 1 when button released, and 0 when button pressed
/////////////////////////////////////////////////////////////////////////////
void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) __wparam
{
	while(!MIOS_DIN_PinGet(4))              //looks for the snap button being down
	lightloop();

}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when an encoder has been moved
// incrementer is positive when encoder has been turned clockwise, else
// it is negative
/////////////////////////////////////////////////////////////////////////////
void ENC_NotifyChange(unsigned char encoder, char incrementer) __wparam
{
}

/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a pot has been moved
/////////////////////////////////////////////////////////////////////////////
void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam
{

  MIOS_MIDI_BeginStream();
  MIOS_MIDI_TxBufferPut(0xb0+pin); // pin= channel number OxB*
  MIOS_MIDI_TxBufferPut(0x07);  // volume cc message
  MIOS_MIDI_TxBufferPut(MIOS_AIN_Pin7bitGet(pin)); // don't send 10bit pin_value, but 7bit value
  MIOS_MIDI_EndStream();
	potscan();
	showem();

}

Link to comment
Share on other sites

Many thanks George, I'll digest that over the coming days.

One further question, if I were to use a HD44780 20x4 display, will it work "out of the box" with an application written in C?  Will I be able to address all the displays positions using MIOS_LCD_CursorSet, or must there be an extra driver?

James

Link to comment
Share on other sites

James,

Keep in mind it's not as "big" as it looks. A bunch of it is just default "main file" stuff which was already there, then you've got that light flashing crap and the DIN stuff that doesn't have anything to with the AIN part (or need to be there).

I also should have mentioned that if you see any weird variable letters, they don't mean anything. I use the standard temporary/count letter "i" a bunch, but sometimes I'll use whatever random crap comes to mind.  (didn't expect myself to have to read that, let alone anyone else ;))

George

PS- You've probably noticed now, but the "Val - " gets drawn across both lines and stays there (4x per line), then on pot value draws, the current values get written into the blank space across the lines (without clearing the screen) and on each consecutive value, the cursor position gets moved over 10 spaces or so to the right, so they land in the empty space after each "Val - ". The first one obviously needs to start a few spaces over as well (looks like the "j" variable).

*** I can clean that mess up a bit and comment it, but I'd rather have someone point out all the other stuff that's really wrong with it first. ;D   

Link to comment
Share on other sites

James.

Wow, I'm late. I've been away.

I understand that C is preferred, but I do have

a horizonital bar display written in asm.

It's also stereo, offering separate left and

right bars "growing" out from the middle.

I don't know if all HD44780 displays have

the same special characters, but if you'd like

to check it out anyway, just grab the code for

MBMixer and look in the user_LCD file, I think.

I tried to comment a bit heavy, to break down

each step of the code.

As it is written now, it uses all of the bottom

line of a 2X20 VFD.

Maybe you'll find something useful in it.

Lyle

http://www.midibox.org/dokuwiki/doku.php?do=show&id=midiboxmixer

Link to comment
Share on other sites

Okay, I've purchased a 4*20 LCD display and wired it up to the core (which is running midio128) using Jim Henry's excellent tutorial.  The backlight comes on, but no characters are displayed.  Should I expect to see something with midio128, or is this application only compatible with a 2*16 display?

Thanks,

James

Link to comment
Share on other sites

The mystery continues.  I've wired up a standard 2*16 display, and I am getting the same result.  I've checked and double checked my wiring and all seems well, I've also checked and rechecked the soldering on the core and that seems well.  The core is working well with midio128.  Any thoughts on what might be wrong?

Thanks,

James

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...