/* Programmer: Ryan Blajda */ //Compiler Directives // #ENABLE_DYNAMIC #SYMBOL_NAME "Raspberry Pi String Formatterv2.0" #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 constDelimiter "/x00/" STRING_INPUT movieGenre[50]; STRING_INPUT currentThumbnail[400]; //DIGITAL_INPUT updateThumbnail; STRING_OUTPUT toRaspberryPi; DIGITAL_INPUT systemStatus; DIGITAL_OUTPUT poll; ANALOG_INPUT activeSource; ANALOG_INPUT redLevel; ANALOG_INPUT greenLevel; ANALOG_INPUT blueLevel; INTEGER systemState; STRING storeMovieGenre[15]; STRING storeThumbnail[400]; //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); } STRING_FUNCTION formatOutputString(string delimiter, integer state, integer source, integer red, integer green, integer blue, string genre, string thumbnail){ STRING prefix[5]; STRING formattedString[1000]; STRING sourceString[5]; STRING stateString[5]; STRING redString[5]; STRING greenString[5]; STRING blueString[5]; prefix = "x0"; redString = itoa(red); greenString = itoa(green); blueString = itoa(blue); stateString = itoa(state); sourceString = itoa(source); formattedString = prefix + stateString + delimiter + prefix + sourceString + delimiter + redString + delimiter + greenString + delimiter + blueString + delimiter + genre + delimiter + thumbnail; return(formattedString); } PUSH systemStatus { systemState = 2; } RELEASE systemStatus { systemState = 1; } CHANGE systemStatus, activeSource, movieGenre, currentThumbnail { STRING formattedMovieGenre[15]; storeMovieGenre = movieGenre; storeThumbnail = currentThumbnail; formattedMovieGenre = shortenMovieGenre(storeMovieGenre); toRaspberryPi = formatOutputString(constDelimiter, systemState, activeSource, redLevel, greenLevel, blueLevel, formattedMovieGenre, storeThumbnail); }