Go Down

Topic: YAMAHA YSP-4000 IR hex codes and how to store them for an ESP8266-12E (Read 2021 times) previous topic - next topic

flewis

Hi all,

Using a service manual for a YAMAHA YSP-4000 and some handy info from the below link, I've been able to come up with the following list of hex codes to control my YSP-4000 sound projector (which I've tentatively put in an array) which was missing a remote. Using an ESP8266-12E, the PubSubClient and IRremoteESP8266 libraries, I've got power, Volume up and down controllable by MQTT, only where I've hardcoded them.

My hope is to pass the short-form name for each function, such as "PWR_TOGGLE" via MQTT, the ESP would find that name in an array, then send the adjacent hex code with the irsend() function, as in my callback function below. I'm not sure whether an array is the wisest way to store the data, since I've got both names and hex codes of different types compiled together.

I imagine that an array of some form would make sense, rather than hardcoding them, even if i had separate arrays for names and the codes, as then i could iterate through the codes to generate a GUI, whether on an LCD screen, or on a webform.

I feel the way i'm doing it currently is clumsy and messy, as I'm only an amateur, but hopefully these codes may be of use to others!

http://nobbin.net/2012/12/08/converting-yamaha-nec-infrared-codes-to-lirc-format/

Code: [Select]
String hexCodes[243] = {
"PWR_TOGGLE","0x1EE133CC",
"MUTE_TOGGLE","0x1EE139C6",
"FM_XM","0x1EE1D22D",
"TV_STB","0x1EE1FB04",
"DVD","0x1EE152AD",
"AUX1","0x1EE1926D",
"AUX2","0x1EE17B84",
"AUX3","0x1EE13DC2",
"INPUT_MODE","0x1EE1B14E",
"VOL_UP","0x1EE17887",
"VOL_DOWN","0x1EE1F807",
"SLEEP_TIMER","0x1EE1F20D",
"TEN_KEY0","0x1EE108F7",
"TEN_KEY1","0x1EE18877",
"TEN_KEY2","0x1EE148B7",
"TEN_KEY3","0x1EE1C837",
"TEN_KEY4","0x1EE128D7",
"TEN_KEY5","0x1EE1A857",
"TEN_KEY6","0x1EE16897",
"TEN_KEY7","0x1EE1E817",
"TEN_KEY8","0x1EE118E7",
"TEN_KEY9","0x1EE19867",
"PRESET_PLUS","0x1EE1D827",
"PRESET_MINUS","0x1EE138C7",
"ABCDE_PLUS","0x1EE1B847",
"ABCDE_MINUS","0x1EE1DD22",
"TUNING_PLUS","0x1EE155AA",
"TUNING_MINUS","0x1EE1956A",
"PRESET_TUNE","0x1EE115EA",
"SEARCH_MODE","0x1EE1ED12",
"MEMORY","0x1EE14DB2",
"XM_ENTER","0x1EE1BD42",
"XM_DISPLAY","0x1EE11DE2",
"SURROUND","0x1EE19966",
"DSP_MOVIE","0x1EE19B64",
"DSP_MUSIC","0x1EE15BA4",
"DSP_SPORTS","0x1EE1DB24",
"DSP_OFF","0x1EE1D926",
"MUSIC_ENHANCER","0x1EE1D32C",
"VOLUME_MODE","0x1EE151AE",
"SRS_TRUBASS","0x1EE1D12E",
"SOUND_LEVEL","0x1EE112ED",
"DOLBY_TEST","0x1EE1FA05",
"BEAM_5","0x1EE143BC",
"BEAM_ST_3","0x1EE1C33C",
"BEAM_3","0x1EE123DC",
"BEAM_STEREO_5CH","0x1EE10AF5",
"BEAM_MY","0x1EE1A35C",
"BEAM_SURROUND","0x1EE1639C",
"SET_MENU","0x1EE1B946",
"INTELLIBEAM","0x1EE1C53A",
"UP","0x1EE1718E",
"DOWN","0x1EE1F10E",
"RIGHT","0x1EE17986",
"LEFT","0x1EE1F906",
"ENTER","0x1EE1837C",
"RETURN","0x1EE103FC",
"POWER_ON","0x1EE17E81",
"POWER_OFF","0x1EE1FE01",
"MUTE_ON","0x7E8145BA",
"MUTE_20DB","0x7E81FB04",
"MUTE_OFF","0x7E81C53A",
"INPUT_FM","0x1EE16D92",
"INPUT_XM","0x1EE1BE41",
"INPUT_AUTO","0x7E81659A",
"DTS","0x7E8115EA",
"ANALOG","0x7E8155AA",
"AAC","0x7E81DC23",
"SLEEP_OFF","0x7E81CD32",
"SLEEP_120","0x7E812DD2",
"SLEEP_90","0x7E81AD52",
"SLEEP_60","0x7E816D92",
"SLEEP_30","0x7E81ED12",
"PRESET_PAGE_A","0x1EE1F50A",
"PRESET_PAGE_B","0x1EE1758A",
"PRESET_PAGE_C","0x1EE1B54A",
"PRESET_PAGE_D","0x1EE135CA",
"PRESET_PAGE_E","0x1EE1D52A",
"AUTOSEARCH_PLUS","0x1EE18D72",
"AUTOSEARCH_MINUS","0x1EE10DF2",
"SEARCH_ALL","0x1EE1E619",
"SEARCH_PRESET","0x1EE116E9",
"NIGHT_CINEMA","0x7E81D926",
"NIGHT_MUSIC","0x7E81F30C",
"NIGHT_OFF","0x7E8139C6",
"TV_MODE_ON","0x1EE13EC1",
"TRUBASS_DEEP","0x1EE17689",
"TRUBASS_MID","0x1EE1B649",
"TRUBASS_OFF","0x1EE1F609",
"BEAM_5CH","0x7E81FF00",
"PRO_LOGIC","0x7E81BF40",
"PROLOGIC_MOVIE","0x7E81E619",
"PROLOGIC_MUSIC","0x7E8116E9",
"PROLOGIC_GAME","0x7E81E31C",
"NEO6_MOVIE","0x7E819669",
"NEO6_MUSIC","0x7E8156A9",
"NEURAL_SURROUND","0x7E8133CC",
"CINE_DSP_SPEC","0x7E819F60",
"CINE_DSP_SFX","0x7E815FA0",
"CINE_DSP_ADV","0x7E81DF20",
"CINE_DSP_CONCERT","0x7E818778",
"CINE_DSP_JAZZ","0x7E8137C8",
"CINE_DSP_MUSICVID","0x7E81CF30",
"CINE_DSP_SPORTS","0x7E811FE0",
"MUSIC_ENHANCER_HI_ON","0x7E811BE4",
"MUSIC_ENHANCER_HI_OFF","0x7E819B64",
"PRESET_MEM_A","0x1EE10EF1",
"PRESET_MEM_B","0x1EE14EB1",
"PRESET_MEM_C","0x1EE12ED1",
"PRESET_CALL_A","0x1EE18E71",
"PRESET_CALL_B","0x1EE1CE31",
"PRESET_CALL_C","0x1EE1AE51",
"MEM_SAVE_U1","0x1EE16E91",
"MEM_SAVE_U2","0x1EE11EE1",
"MEM_SAVE_U3","0x1EE15EA1",
"MEM_LOAD_U1","0x1EE1EE11",
"MEM_LOAD_U2","0x1EE19E61",
"MEM_LOAD_U3","0x1EE1DE21",
"DEMO_ON","0x1EE1D629",
"DEMO_OFF","0x1EE136C9"
}


Code: [Select]
void callback(char* topic, byte* payload, unsigned int length) {
  int i = 0;
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i = 0; i < length; i++) {
    message_buff[i] = payload[i];
    Serial.print((char)payload[i]);
  }
  message_buff[i] = '\0';
  String msgString = String(message_buff);
  Serial.println();

  //rough prototype
  for (int i = 0; i < length; i++) {
    if (msgString == hexCodes[i]) {
      irsend.sendNEC(hexCodes[i+1], 32);
      Serial.println(hexCodes[i]);
    }
  }

  // Switch on the LED if an 1 was received as first character
  if ((char)payload[0] == '1') {
    digitalWrite(ONBOARDLED_PIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
    // but actually the LED is on; this is because
    // it is acive low on the ESP-01)
  } else if ((char)payload[0] == '0') {
    digitalWrite(ONBOARDLED_PIN, HIGH);  // Turn the LED off by making the voltage HIGH
  } else if ((char)payload[0] == '+') {
                   Serial.println("NEC");
                   irsend.sendNEC(0x1EE17887, 32); //or 16 bit?
                   Serial.println("VOL UP");
  } else if ((char)payload[0] == '-') {
                   Serial.println("NEC");
                   irsend.sendNEC(0x1EE1F807, 32);
                   Serial.println("VOL DOWN");
  } else if ((char)payload[0] == 'P') {
                   Serial.println("NEC");
                   irsend.sendNEC(0x1EE133CC, 32);
                   Serial.println("PWR TOGGLE");
  }

}

flewis

Can Strings or strings be stored in an array alongside "Ox1EE17887" format hex codes, and the hex codes still be pulled out and reformatted efficiently to be sent to the irsend.sendNEC() function?

rw950431

Assuming you are using the IR Send library from https://www.pjrc.com/teensy/td_libs_IRremote.html then the issue is that the sendNEC function needs a number (0x1EE133CC is the the hex representation of the decimal number 518075340) not a string as you have supplied. 

It may be easier to store the codes as two arrays so you lookup the input string in one and read the result in the other.

Code: [Select]
String cmds[122] = {
"PWR_TOGGLE",
"MUTE_TOGGLE"
 //etc
}

unsigned long codes[122] = {
0x1EE133CC,
0x1EE139C6,
//etc
}

for (int i = 0; i < length; i++) {
    if (msgString == cmds[i]) {
      irsend.sendNEC(codes[i], 32);
      Serial.println(hexCodes[i]);
      break;
    }
  }
}


Alternatively you could use an array of structs (http://forum.arduino.cc/index.php?topic=43587.0)

flewis

Thanks man! I ended up cobbling together something which seems to be working, I'll try to throw the code up when I get a chance. Hope it might help someone.

Go Up