' 'color blending and absolute thermometer ' ' 'A piece of modern tech art that pulses and blends colors 'and indicates morse-code flash encoded temperature every so often ' ' 'Uses a DS18B20 to sense temperature, Bi-color LED to indicate temp ' ' 'Changelog ' v1 initial version - based on RELATIVE_TERMOMETER_6 ' '(C)2007 by A. Stein, MedCosm, LLC ' ' ' ' 08M variable table (for convenience) ' b0:b1 b2:b3 b4:b5 b6:b7 b8:b9 b10:b11 b12:b13 ' w0 w1 w2 w3 w4 w5 w6 ' pinouts symbol LEDred=2 'LED1 (red) pin, also used to sense light! symbol LEDgreen=1 'LED2 (green) pin symbol TempSense=4 'DS18B20 pin 'variables symbol LEDvalue=b0 'Byte Red/Green value of LED when at full intensity symbol intensity=b1 'intensity of LED symbol TReading = W1 'temp reading from DS18B20 in F*100 symbol tmpW1=w2 'tmp word variable symbol tmpB1=b6 'tmp byte variable symbol tmpB2=b7 'tmp byte variable symbol flashNum=b8 'tmp byte variable symbol flashDigit=b9 'tmp byte variable symbol rndW=w5 'random word symbol rndB1=b10 symbol redValue=b12 symbol greenValue=b13 'constants symbol maxIntensity=50 'max value that is of LED intensity 'symbol maxLEDvalue=255 'max value held by LEDvalue (Red/Green encoding), since 255, doesn't need scaling symbol numPWMcycles=1 symbol flashDotDuration=400 'duration of flash during morse code number encoding symbol flashDashDuration=flashDotDuration*3 symbol numFlashCyclesDot=20 symbol numFlashCyclesDash=numFlashCyclesDot*3 symbol numBlends=4 'number of colorblends symbol sleepBtwnBlends=2 'delay between blends init: rndW=12345 start: gosub getTemp setfreq m8 'overclock reduces flicker flashDigit=TReading/1000 'flashDigit=temp (F) tens digit gosub flashnumber 'serTxD(#flashDigit) flashDigit=TReading/100 flashDigit= flashDigit % 10 'flashDigit=temp (F) ones digit gosub flashnumber 'serTxD(#flashDigit, 13,10) sleep sleepBtwnBlends for tmpB1=1 to numBlends random rndW LEDvalue=rndB1 gosub pulse sleep sleepBtwnBlends next tmpB1 setfreq m4 'restore normal clock so new downloads aren't screwed up goto init 'routine to flash temp in morse code '(flashDigit, LEDvalue) flashnumber: intensity=maxIntensity if flashDigit<=5 then flashNum=flashDigit gosub flashDot flashNum=5-flashDigit gosub flashDash else flashNum=flashDigit-5 gosub flashDash flashNum=10-flashDigit gosub flashDot endif pause flashDashDuration return 'flash number of dots '(flashNum) flashDot: if flashNum>=1 then for tmpB1=1 to flashNum for tmpB2=1 to numFlashCyclesDot gosub glowBlend next pause flashDotDuration next endif return 'flash number of dashes '(flashNum) flashDash: if flashNum>=1 then for tmpB1=1 to flashNum for tmpB2=1 to numFlashCyclesDash gosub glowBlend next pause flashDotDuration next endif return 'pulse LED, rampup then rampdown pulse: 'rampup: 'rampup LED brightness for intensity=0 to MaxIntensity step 1 gosub glowBlend next intensity 'serTxD(13,10) 'rampdown: 'rampdown LED brightness for intensity=MaxIntensity to 0 step -1 gosub glowBlend next intensity return 'display blended colors on LED glowBlend: tmpW1=LEDvalue 'scale LEDvalue to full byterange redValue=tmpW1 'save intermediate tmpW1=tmpW1 * intensity / MaxIntensity 'RED value adjusted for intensity pwm LEDred, tmpW1, numPWMcycles tmpW1=255-redValue 'GREEN LEDvalue tmpW1=tmpW1 * intensity / MaxIntensity pwm LEDgreen, tmpW1, numPWMcycles return getTemp: readTemp12 TempSense,TReading 'acq temp ' tmpB1 = TReading / 256 / 128 'tmpB1 is signbit tmpB1 = TReading / 32768 'tmpB1 is signbit, more memory efficient if tmpB1 = 1 then 'if its negative TReading = TReading ^ $ffff + 1 ' take twos comp endif tmpW1 = TReading * 6 ' TC = value * 0.0625 TReading = TReading * 25 / 100 tmpW1 = tmpW1 + TReading 'temp is now in C*100 tmpW1 = tmpW1 * 9 / 5 'convert to F tmpW1 = tmpW1 + 3200 'temp is now in F*100 TReading = tmpW1 'set TReading to temp (F*100) return