/* Programmer: Ryan Blajda */ //Compiler Directives // #ENABLE_DYNAMIC #SYMBOL_NAME "Raspberry Pi String Formatter" #HINT "raspithing" #CATEGORY "4" // Device Interface #DEFAULT_VOLATILE #ENABLE_STACK_CHECKING #ENABLE_TRACE /* #HELP_BEGIN (add additional lines of help lines) #HELP_END */ //Constants & Variables #DEFINE_CONSTANT delimiter "/x00/" #DEFINE_CONSTANT appleTVSTring "/x01/x00/" #DEFINE_CONSTANT genreString "/x02/x00/" #DEFINE_CONSTANT activeSourceString "/x03/x00/" #DEFINE_CONSTANT thumbnailString "/x04/x00/" STRING_INPUT movieGenre[50]; STRING_INPUT currentThumbnail[400]; STRING_OUTPUT toRaspberryPi; DIGITAL_INPUT kodiPlayPress; DIGITAL_INPUT appleTVActive; ANALOG_INPUT redLevel; ANALOG_INPUT greenLevel; ANALOG_INPUT blueLevel; INTEGER sendingMovieGenre; STRING piMovieGenre[15]; STRING piAppleTVLEDColor[50]; STRING movieGenrePlaceholder[15]; //Functions STRING_FUNCTION shortenMovieGenre(string movieGenreInput){ STRING matchString[1]; INTEGER commaLocation; STRING shortenedGenre[15]; matchString = ","; commaLocation = find(matchString, movieGenreInput); commaLocation = commaLocation - 1; if (commaLocation != 0){ shortenedGenre = removebylength(commaLocation, movieGenreInput); } else { print("Comma Was Not Found"); } return(shortenedGenre); } //Event Handlers PUSH kodiPlayPress { piMovieGenre = shortenMovieGenre(movieGenrePlaceholder); sendingMovieGenre = 1; toRaspberryPi = genreString + pimovieGenre; } RELEASE kodiPlayPress { movieGenrePlaceholder = movieGenre; sendingMovieGenre = 0; toRaspberryPi = thumbnailString + currentThumbnail; } PUSH appleTVActive { STRING redString[5]; STRING greenString[5]; STRING blueString[5]; redString = itoa(redLevel); greenString = itoa(greenLevel); blueString = itoa(blueLevel); toRaspberryPi = appleTVString + redString + delimiter + greenString + delimiter + blueString; }