Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --SATFINDER PORTABLE Version 1.3 - Español
- -- Ready to be used with LuaPlayerHM6.5
- --Satfinder has been created by:
- --Pedro J. Fernández - [email protected]
- --Guillermo Fernández - [email protected]
- --Special thanks to:
- --Razorblade - [email protected]
- --Dr. T.S.Kelso - [email protected]
- --John Walker (Home Planet) - http://www.fourmilab.ch/
- --John A. Magliacane (Predict) - http://www.qsl.net/kd2db/
- function screen.height()
- return 272
- end
- function screen.width()
- return 480
- end
- function SF_initialize()
- -- Inicialiamos algunos colores
- sf_color_white = color.new(255,255,255)
- sf_color_black = color.new(0,0,0)
- sf_color_red = color.new (255,0,0)
- sf_palette = {}
- sf_star_palette = {}
- sf_palette_len = 16
- sf_color_day = {}
- sf_color_night = {}
- sf_color_day.r = 0
- sf_color_day.g = 255
- sf_color_day.b = 0
- sf_color_night.r = 255
- sf_color_night.g = 0
- sf_color_night.b = 0
- SF_changePalette (sf_color_day.r,sf_color_day.g,sf_color_day.b)
- SF_crearPaletaEstrellas()
- sf_selected_sat = 0
- -- Borramos las dos pantallas (doble buffer)
- screen.clear(sf_color_black)
- screen.waitvblankstart()
- screen.flip()
- screen.clear(sf_color_black)
- screen.waitvblankstart()
- screen.flip()
- local file = io.open("update.txt")
- local mensaje
- if file then
- local line = file:read("*l")
- local update_jt = tonumber(line)
- if update_jt ~= nil then
- local ct = os.date("*t")
- -- This functions only works in LuaPlayerHM6.5
- ct.year = tonumber(os.date("%Y"))
- ct.month = tonumber(os.date("%m") )
- ct.day = tonumber(os.date("%d"))
- ct.hour = tonumber(os.date("%I"))
- if string.lower(os.date("%p")) == "pm" then
- ct.hour = ct.hour + 12.0
- end
- ct.min = tonumber(os.date("%M"))
- ct.sec = tonumber(os.date("%S"))
- -- current_time.year , month, day, hour, min, sec, isdst
- local jt = SGP_Date_To_Julian(ct.year, ct.month, ct.day, ct.hour, ct.min, ct.sec)
- local diff = jt - update_jt
- local dias_julianos = diff
- screen.print(440, 261, "v1.3", sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(440, 261, "v1.3", sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 1, "> Comprobando edad de los ficheros TLE: "..string.format("%.2f",dias_julianos).." dias" , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 1, "> Comprobando edad de los ficheros TLE: "..string.format("%.2f",dias_julianos).." dias" , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- if dias_julianos > 3 then
- screen.print(1, 11, " Los arhivos TLE son demasiado viejos!" , sf_color_red)
- screen.print(1, 21, " Actualiza con SatFinder Updater o via WIFI." , sf_color_red)
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 11, " Los arhivos TLE son demasiado viejos!" , sf_color_red)
- screen.print(1, 21, " Actualiza con SatFinder Updater o via WIFI." , sf_color_red)
- screen.waitvblankstart()
- screen.flip()
- else
- screen.print(1, 11, " Los arhivos TLE son suficientemente recientes.", sf_palette[1])
- screen.print(1, 21, " No es necesario actualizar." , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 11, " Los arhivos TLE son suficientemente recientes.", sf_palette[1])
- screen.print(1, 21, " No es necesario actualizar." , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- end
- end
- end
- screen.print(1, 31, "> Comprobando asistente de voz... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 31, "> Comprobando asistente de voz... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- --System.oaenable();
- local sound_welcome = sound.load("SatFinder/welcome.wav",false)
- sound_welcome:play()
- screen.waitvblankstart(5)
- while sound_welcome:playing() do
- screen.waitvblankstart(5)
- end
- screen.print(274, 31, "OK!" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(274, 31, "OK!" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 41, "> Definiendo constantes... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 41, "> Definiendo constantes... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- -- Constantes
- SF_constants()
- SGP_initCoefficients()
- screen.print(216, 41, "OK!" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(216, 41, "OK!" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 51, "> Definiendo variables... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 51, "> Definiendo variables... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- -- Sky configuration
- sf_sky_color = color.new(0,0,0)
- sf_sky = {}
- sf_sky.radio = 241
- sf_sky.centro = {}
- sf_sky.centro.x = 241
- sf_sky.centro.y = 137
- sf_sky.elevacion_minima = 0
- sf_sky.color = sf_color_black
- sf_sky.orientacion = -1.0
- sf_sky.rotacion = 0.0
- sf_sky.show = {}
- sf_sky.show.satellites = true
- sf_sky.show.satelliteNames = false
- sf_sky.show.stars = true
- sf_sky.show.autoMagStars = false
- sf_sky.show.constellationNames = false
- sf_sky.show.sunAndMoon = true
- sf_sky.show.elevationLines = true
- sf_next_visible_results = {}
- sgp_sun = {}
- sgp_sun.raise = {}
- sgp_sun.set = {}
- sgp_location = {}
- sgp_location.polar = {}
- sgp_location.day = {}
- sgp_location.night = {}
- sgp_moon = {}
- sgp_moon.age = {}
- sgp_moon.raise = {}
- sgp_moon.set = {}
- local i
- sf_pass_max = 23
- sf_pass_limit = 0
- sf_pass_current = 0
- sf_passes = {}
- for i = 1,sf_pass_max do
- sf_passes[i] = {}
- end
- sf_pass_path = {}
- sf_pass_path.longitud = 0
- sf_pass_path.max = 256
- for i = 1,sf_pass_path.max do
- sf_pass_path[i] = {}
- end
- sf_primera_busqueda = true
- sf_next_visible_show_info = false
- sf_next_visible_precision = 0.4
- sf_primer_calculo = true
- sf_vision_nocturna = true
- sf_moving_sky = false
- sf_zoom_mode = false
- sf_moon_wait = 0
- sf_sun_wait = 0
- -- Carga de imagenes en memoria
- bitmap_sol = image.load("SatFinder/sol.png")
- bitmap_cruz = image.load("SatFinder/cruz.png")
- bitmap_luna = image.load("SatFinder/luna_dia.png")
- screen.print(208, 51, "OK!" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(208, 51, "OK!" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 61, "> Cargando configuracion... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 61, "> Cargando configuracion... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- if SF_loadConfigFromFile("config.txt") then
- screen.print(216, 61, "OK!" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(216, 61, "OK!" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- else
- screen.print(216, 61, "Usando valores por defecto." , sf_color_red)
- screen.waitvblankstart()
- screen.flip()
- screen.print(216, 61, "Usando valores por defecto." , sf_color_red)
- screen.waitvblankstart()
- screen.flip()
- end
- screen.print(1, 71, "> Cargando satelites... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 71, "> Cargando satelites... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- -- Satelites
- sgp_sats = { }
- sgp_sat_number = 0 -- esta variable tiene que ser cero y se modifica por SGP_getTLE()
- SGP_getTLE("./tle/visual.tle")
- SGP_getTLE("./tle/iridium.tle")
- if sgp_sat_number == -1 then
- screen.print(192, 71, "Error: Archivos TLE corruptos." , sf_color_red)
- screen.waitvblankstart()
- screen.flip()
- screen.print(192, 71, "Error: Archivos TLE corruptos." , sf_color_red)
- screen.waitvblankstart()
- screen.flip()
- sgp_sat_number = 0
- elseif sgp_sat_number == -2 then
- screen.print(192, 71, "Error: Faltan archivos TLE." , sf_color_red)
- screen.waitvblankstart()
- screen.flip()
- screen.print(192, 71, "Error: Faltan archivos TLE." , sf_color_red)
- screen.waitvblankstart()
- screen.flip()
- sgp_sat_number = 0
- else
- screen.print(192, 71, "OK! (".. sgp_sat_number..")" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(192, 71, "OK! (".. sgp_sat_number..")" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- end
- sf_next_max = sgp_sat_number
- sf_next_limit = 0
- sf_next_current = 0
- sf_next_passes = {}
- for i = 1,sf_next_max do
- sf_next_passes[i] = {}
- end
- screen.print(1, 81, "> Cargando estrellas... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 81, "> Cargando estrellas... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- sgp_mag_limit = 3.4
- sgp_mag_max = 4.2
- sf_star_update_rate_limit = 10
- sf_star_update_current_rate = 1
- sgp_star_number = 0
- sgp_constellation_number = 0
- SGP_getStars("allstars.txt", sgp_mag_max)
- screen.print(192, 81, "OK! (" .. sgp_star_number ..")", sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(192, 81, "OK! (" .. sgp_star_number ..")", sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 91, "> Cargando informacion del observador... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 91, "> Cargando informacion del observador... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- -- Localizacion de observacion
- if not SGP_getLocationFromFile("location.txt") then
- SGP_setLocation(39.232, -6.536, 80, 1, "Defecto", false)
- screen.print(322, 91, "Usando informacion por defecto." , sf_color_red)
- screen.waitvblankstart()
- screen.flip()
- screen.print(322, 91, "Usando informacion por defecto." , sf_color_red)
- screen.waitvblankstart()
- screen.flip()
- else
- screen.print(322, 91, "OK!" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(322, 91, "OK!" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- end
- screen.print(1, 101, "> Calculando posicion de los satelites... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 101, "> Calculando posicion de los satelites... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- end
- function SF_clacularOtrosDatos()
- screen.print(330, 101, "OK!" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(330, 101, "OK!" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 111, "> Calculando fases lunares... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 111, "> Calculando fases lunares... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- SGP_calculateMoonPhases ()
- screen.print(234, 111, "OK!" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(234, 111, "OK!" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 121, "> Calculando amaneceres y ocasos... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 121, "> Calculando amaneceres y ocasos... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- SGP_calculateSunRaiseTime()
- SGP_calculateSunSetTime()
- SGP_calculateNightBegining()
- SGP_calculateNightEnding()
- SGP_calculateMoonRaiseTime()
- SGP_calculateMoonSetTime()
- screen.print(282, 121, "OK!" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(282, 121, "OK!" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 131, "> Procesando estrellas, espere... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(1, 131, "> Procesando estrellas, espere... " , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- end
- function SGP_getCurrentTime()
- if not sf_primer_calculo then
- sgp_last_time = sgp_time
- end
- sgp_time = os.date("*t")
- -- This functions only works in LuaPlayerHM6.5
- sgp_time.year = System.getDate(1)
- sgp_time.month = System.getDate(2)
- sgp_time.day = System.getDate(3)
- sgp_time.hour = System.getTime(1)
- if System.getTime(5) == "pm" then
- sgp_time.hour = sgp_time.hour + 12.0
- end
- sgp_time.min = System.getTime(2)
- sgp_time.sec = System.getTime(3)
- sgp_time.isdst = sgp_location.dst
- sgp_time.jtime = SGP_Date_To_Julian(sgp_time.year, sgp_time.month, sgp_time.day, sgp_time.hour, sgp_time.min, sgp_time.sec)
- sgp_time.ujtime = SGP_Local_to_UTC(sgp_time.jtime)
- sgp_time.uyear,sgp_time.umonth,sgp_time.uday,sgp_time.uhour,sgp_time.umin,sgp_time.usec = SGP_Julian_To_Date(sgp_time.ujtime)
- if sf_primer_calculo then
- sgp_last_time = sgp_time
- end
- end
- function SF_drawTextMap(latitud, longitud, texto, color)
- local px, py = SF_LatLonToXY(latitud, longitud)
- local len = texto:len()
- if latitud > 0 then
- py = py-4 + 8
- else
- py = py-4 - 8
- end
- screen.print(px, py, texto, color)
- end
- function SF_AzElevToXY( azimut, elevacion )
- local distanciaCentro = sf_sky.radio * ((90.0-elevacion)/90.0) * (90 / (90-sf_sky.elevacion_minima))
- local x, y
- local azimut_rotated = azimut + sf_sky.rotacion;
- x = sf_sky.radio + (distanciaCentro * math.sin(azimut_rotated*math.pi/180.0) * sf_sky.orientacion)
- y = sf_sky.radio - distanciaCentro * math.cos(azimut_rotated*math.pi/180.0)
- x = x + (sf_sky.centro.x - sf_sky.radio)
- y = y + (sf_sky.centro.y - sf_sky.radio)
- return x , y
- end
- function SF_drawTextSky(azimut, elevacion, texto, color)
- local txt
- if texto == nil then
- txt = "nil"
- else
- txt = texto
- end
- if elevacion > sf_sky.elevacion_minima then
- local px, py = SF_AzElevToXY( azimut, elevacion )
- local longitud = texto:len()
- screen.print(px-2-((longitud-1)*4), py-2, txt, color)
- end
- end
- function SF_drawPointSky( azimut , elevacion , color )
- if elevacion > sf_sky.elevacion_minima then
- local px, py = SF_AzElevToXY( azimut, elevacion )
- if px > 0 and px < screen.width()-1 and py > 0 and py < screen.height()-1 then
- image.pixel( px , py , color )
- return true
- end
- end
- return false
- end
- function SF_LatLonToXY(latitud, longitud)
- local x, y
- y = math.floor(latitud * 1.51111)
- x = math.floor(longitud * 1.33333)
- x = 240 + x
- y = 136 - y
- return x, y
- end
- function SF_drawPointMap( latitud , longitud , color )
- local px, py = SF_LatLonToXY(latitud, longitud)
- if px > 0 and px < screen.width() and py > 0 and py < screen.height() then
- image.pixel( px , py , color )
- end
- end
- function SF_drawCircleSky(radio,azimut,elevacion,color)
- local px, py = SF_AzElevToXY( azimut, elevacion )
- x0 = math.sin(math.pi-0/32*2*math.pi) * radio + px
- y0 = math.cos(math.pi-0/32*2*math.pi) * radio + py
- for i=1,64 do
- x1 = math.sin(math.pi-i/32*2*math.pi) * radio + px
- y1 = math.cos(math.pi-i/32*2*math.pi) * radio + py
- if x1 > 0 and x1 < screen.width() and y1 > 0 and y1 < screen.height() then
- if x0 > 0 and x0 < screen.width() and y0 > 0 and y0 < screen.height() then
- draw.line(x0, y0, x1, y1, color)
- end
- end
- x0 = x1
- y0 = y1
- end
- end
- function SF_drawElevationLine (elevacion, color)
- local azimut = 0
- if elevacion >= 0 and 90 > elevacion then
- local px, py = SF_AzElevToXY( -sf_sky.rotacion, elevacion )
- SF_drawCircleSky(py - sf_sky.centro.y, 0, 90, color)
- elseif elevacion == 90 then
- SF_drawPointSky(azimut, elevacion, color)
- end
- end
- function SF_drawLineSky( azimut1 , elevacion1 , azimut2, elevacion2, color )
- if ((elevacion1 > sf_sky.elevacion_minima) and (elevacion2 > sf_sky.elevacion_minima)) then
- local x1, y1 = SF_AzElevToXY( azimut1, elevacion1 )
- local x2, y2 = SF_AzElevToXY( azimut2, elevacion2 )
- if x1 > 0 and x1 < screen.width() and y1 > 0 and y1 < screen.height() then
- if x2 > 0 and x2 < screen.width() and y2 > 0 and y2 < screen.height() then
- draw.line( x1, y1, x2, y2, color)
- end
- end
- end
- end
- function SF_drawElevation()
- SF_drawElevationLine (0,sf_palette[14])
- SF_drawElevationLine (30,sf_palette[14])
- SF_drawElevationLine (60,sf_palette[14])
- SF_drawElevationLine (90,sf_palette[14])
- --SF_drawText("30", 300 , 26 , sf_palette[8])
- --SF_drawText("60", 300 , 56 , sf_palette[8])
- SF_drawTextSky(300 , 86 , "90", sf_palette[12])
- SF_drawTextSky(120 , 34 , "30", sf_palette[14])
- SF_drawTextSky(120 , 64 , "60", sf_palette[14])
- SF_drawTextSky(120 , 4 , "0" , sf_palette[12])
- end
- function SF_drawNSEW()
- SF_drawTextSky( 0 , 45 , "N", sf_palette[14])
- SF_drawTextSky( 90 , 45 , "E", sf_palette[14])
- SF_drawTextSky( 180 , 45 , "S", sf_palette[14])
- SF_drawTextSky( 270 , 45 , "W", sf_palette[14])
- end
- function SF_drawBitmapSky( azimut , elevacion , bitmap, xini, yini, xlen, ylen )
- if elevacion > 0 then
- local px, py = SF_AzElevToXY( azimut, elevacion )
- image.blit(px - xlen/2, py - ylen/2, bitmap, xini, yini, xlen, ylen, true)
- end
- end
- function SF_dibuarLineasReferencia()
- if sf_r_pressed and not sf_zoom_mode then
- return
- elseif sf_l_pressed then
- SF_drawMap()
- else
- -- Dibujamos los puntos cardinales N, S, E, W (O)
- SF_drawNSEW()
- -- Dibujamos las lineas de elevación con los grados en texto
- if sf_sky.show.elevationLines then
- SF_drawElevation()
- else
- SF_drawElevationLine(0,sf_palette[14])
- SF_drawElevationLine(90,sf_palette[14])
- end
- end
- end
- function SF_procesarSol(ujtime)
- SF_calcularSol(ujtime) -- Rellena los valores de sgp_sun
- SF_dibujarSol()
- end
- function SF_calcularSol(ujtime)
- if sf_sun_wait <= 0 then
- SGP_calculateSun (ujtime)
- sf_sun_wait = 20
- else
- sf_sun_wait = sf_sun_wait - 1
- end
- end
- function SF_dibujarSol()
- --if sf_l_pressed then
- -- screen.print(100,130,"Dibujando mapa",sf_palette[8])
- --end
- if sf_r_pressed and not sf_zoom_mode then
- SF_drawBackgroundInfo()
- SF_drawSunInfo()
- elseif sf_sky.show.sunAndMoon then
- if sf_l_pressed then
- SF_drawBitmapMap(sgp_sun.lat, sgp_sun.lon , bitmap_sol,0,0,bitmap_sol:width(),bitmap_sol:height() )
- elseif sgp_sun.ele > 0 then
- SF_drawBitmapSky(sgp_sun.azi, sgp_sun.ele , bitmap_sol,0,0,bitmap_sol:width(),bitmap_sol:height() )
- end
- end
- end
- function SF_procesarLuna(ujtime)
- SF_calcularLuna(ujtime) -- Rellena los valores de sgp_moon
- SF_dibujarLuna()
- end
- function SF_calcularLuna(ujtime)
- if sf_moon_wait <= 0 then
- SGP_calculateMoon (ujtime)
- sf_moon_wait = 200
- local numero_imagen = sgp_moon.age.cicle * 16 - 0.5
- if numero_imagen < 0 then
- numero_imagen = numero_imagen + 16
- end
- numero_imagen = math.floor(numero_imagen)
- sf_moon_x_desp = numero_imagen * 16
- else
- sf_moon_wait = sf_moon_wait - 1
- end
- end
- function SF_dibujarLuna()
- if sf_sky.show.sunAndMoon then
- if sf_r_pressed and not sf_zoom_mode then
- SF_drawMoonInfo()
- image.blit(218, 172, bitmap_luna, sf_moon_x_desp, 0, 16, 16, true)
- else
- if sf_l_pressed then
- SF_drawBitmapMap(sgp_moon.lat, sgp_moon.lon, bitmap_luna, sf_moon_x_desp, 0, 16, 16)
- else
- if sgp_moon.ele > 0 then
- SF_drawBitmapSky(sgp_moon.azi, sgp_moon.ele, bitmap_luna, sf_moon_x_desp, 0, 16, 16)
- end
- end
- end
- end
- end
- function SF_crearPaletaEstrellas()
- for i = 1 , sf_palette_len do
- local nivel = math.floor(255 * (1-((i-1)/sf_palette_len)))
- sf_star_palette[i] = color.new(nivel,nivel,nivel)
- end
- end
- function SF_cambiarMagnitudAuto()
- local daylight
- if sgp_sun.ele < const_twilightCivil and sgp_sun.ele > const_twilightNautical then
- daylight = (sgp_sun.ele-const_twilightCivil)/(const_twilightNautical-const_twilightCivil)
- elseif sgp_sun.ele >= const_twilightCivil then
- daylight = 0.0
- else
- daylight = 1.0
- end
- sgp_mag_limit = ((sgp_mag_max + 2) * daylight) - 2
- end
- function SF_procesarEstrellas(ujtime)
- if sf_primer_calculo then
- SF_calcularEstrellas(ujtime)
- elseif sf_sky.show.stars and not sf_l_pressed then
- if sf_sky.show.autoMagStars then
- SF_cambiarMagnitudAuto()
- end
- if not sf_moving_sky then
- SF_calcularEstrellas(ujtime)
- end
- SF_dibujarEstrellas()
- end
- end
- function SF_calcularEstrellas(ujtime)
- local star
- if sf_primer_calculo then
- for star = 1,sgp_star_number do
- if sgp_stars[star].no_calcular <= 0 then
- if sgp_stars[star].mag < sgp_mag_max then
- sgp_stars[star].azi, sgp_stars[star].ele = SGP_RADecToAzElev( ujtime,sgp_stars[star].ra,sgp_stars[star].dec,sgp_location.lat, sgp_location.lon)
- if sgp_stars[star].ele < 0 then
- sgp_stars[star].no_calcular = 10 * -sgp_stars[star].ele
- end
- end
- else
- sgp_stars[star].no_calcular = sgp_stars[star].no_calcular - 1
- end
- end
- cursor_stars = 1
- else
- local stars_to_calc = sf_star_update_current_rate
- while stars_to_calc > 0 and cursor_stars < sgp_star_number do
- while ((sgp_stars[cursor_stars].no_calcular > 0) and sgp_stars[cursor_stars].mag < sgp_mag_limit and (cursor_stars < sgp_star_number)) do
- sgp_stars[cursor_stars].no_calcular = sgp_stars[cursor_stars].no_calcular - 1
- cursor_stars = cursor_stars + 1
- end
- if cursor_stars >= sgp_star_number then
- cursor_stars = 1
- if sf_star_update_current_rate + 1 < sf_star_update_rate_limit then
- sf_star_update_current_rate = sf_star_update_current_rate + 1
- else
- sf_star_update_current_rate = sf_star_update_rate_limit
- end
- else
- if sgp_stars[cursor_stars].no_calcular <= 0 then
- if sgp_stars[cursor_stars].mag < sgp_mag_limit then
- sgp_stars[cursor_stars].azi, sgp_stars[cursor_stars].ele = SGP_RADecToAzElev( ujtime,sgp_stars[cursor_stars].ra,sgp_stars[cursor_stars].dec,sgp_location.lat, sgp_location.lon)
- stars_to_calc = stars_to_calc - 1
- if sgp_stars[cursor_stars].ele < 0 then
- sgp_stars[cursor_stars].no_calcular = 10 * -sgp_stars[cursor_stars].ele
- end
- else
- sgp_stars[cursor_stars].no_calcular = sgp_stars[cursor_stars].no_calcular - 1
- end
- else
- sgp_stars[cursor_stars].no_calcular = sgp_stars[cursor_stars].no_calcular - 1
- end
- cursor_stars = cursor_stars + 1
- end
- end
- end
- end
- function SF_dibujarEstrellas()
- if sf_r_pressed and not sf_zoom_mode then
- SF_drawStarsInfo()
- else
- local star, color
- for star = 1,sgp_star_number do
- if sgp_stars[star].mag < sgp_mag_limit then
- if sgp_stars[star].ele > 0 then
- color = math.floor((sgp_stars[star].mag - sf_sky.radio/241*0.2 + 1)/4*16 )
- if color < 1 then
- color = 1
- elseif color > 16 then
- color = 16
- end
- if not SF_drawPointSky(sgp_stars[star].azi, sgp_stars[star].ele , sf_star_palette[color]) then
- sgp_stars[star].no_calcular = 10
- end
- end
- end
- end
- end
- end
- function SF_procesarSatelites(ujtime)
- if sf_primer_calculo then
- SF_calcularSatelites(ujtime)
- SF_dibujarSatelites()
- elseif sf_sky.show.satellites then
- if not sf_moving_sky then
- SF_calcularSatelites(ujtime)
- end
- SF_dibujarSatelites()
- end
- end
- function SF_calcularSatelites(ujtime)
- if sf_primer_calculo then
- --Para cada satélite obtener sus datos para el tiempo actual, incluido el sol
- sf_elevacion_max = 0
- for s = 1,sgp_sat_number do
- --Calcular solo si no está suspendido temporalmente para optimizar recursos
- if sgp_sats[s].no_calcular <= 0 then
- SGP_calculateSatellite (s, ujtime)
- -- Nos vamos quedando con el satélite con elevación más alta
- -- Necesario para los avisos por voz.
- if sgp_sats[s].elevacion > sf_elevacion_max and sgp_sats[s].visible then
- sf_elevacion_max = sgp_sats[s].elevacion
- sf_azimut_max = sgp_sats[s].azimut
- end
- --Optimizacion
- if sgp_sats[s].elevacion < sf_sky.elevacion_minima then
- if sgp_sats[s].elevacion_ant > sgp_sats[s].elevacion then -- bajando por debajo del horizonte
- sgp_sats[s].no_calcular = math.random (30,60)
- else -- subiendo por debajo del horizonte
- sgp_sats[s].no_calcular = math.random (10,30)
- end
- if sgp_sats[s].numero == sf_iss then
- sgp_sats[s].no_calcular = 10
- end
- end
- else
- --Descontar un calculo suspendido
- sgp_sats[s].no_calcular = sgp_sats[s].no_calcular - 1
- end
- end
- cursor_satelite = 1
- else
- while ((sgp_sats[cursor_satelite].no_calcular > 0) and (cursor_satelite < sgp_sat_number)) do
- sgp_sats[cursor_satelite].no_calcular = sgp_sats[cursor_satelite].no_calcular - 1
- cursor_satelite = cursor_satelite + 1
- end
- if cursor_satelite >= sgp_sat_number then
- cursor_satelite = 1
- else
- SGP_calculateSatellite (cursor_satelite, ujtime)
- -- Nos vamos quedando con el satélite con elevación más alta
- -- Necesario para los avisos por voz.
- if sgp_sats[cursor_satelite].elevacion > sf_elevacion_max and sgp_sats[cursor_satelite].visible then
- sf_elevacion_max = sgp_sats[cursor_satelite].elevacion
- sf_azimut_max = sgp_sats[cursor_satelite].azimut
- end
- --Optimizacion
- if sgp_sats[cursor_satelite].elevacion < sf_sky.elevacion_minima then
- if sgp_sats[cursor_satelite].elevacion_ant > sgp_sats[cursor_satelite].elevacion then -- bajando por debajo del horizonte
- sgp_sats[cursor_satelite].no_calcular = math.random (30,60)
- else -- subiendo por debajo del horizonte
- sgp_sats[cursor_satelite].no_calcular = math.random (10,30)
- end
- if sgp_sats[cursor_satelite].numero == sf_iss then
- sgp_sats[cursor_satelite].no_calcular = 10
- end
- end
- cursor_satelite = cursor_satelite + 1
- end
- end
- end
- function SF_dibujarSatelites()
- if sf_primer_calculo then
- sf_vision_nocturna = sgp_location.noche
- sf_tail_length = 16
- sf_step_length = 20
- SF_initTails()
- end
- local s
- if sf_r_pressed and not sf_zoom_mode then
- SF_drawSatsInfo()
- elseif sf_l_pressed then
- for s = 1,sgp_sat_number do
- SF_drawSatMap( s )
- end
- SF_drawSatPathMap()
- else
- for s = 1,sgp_sat_number do
- if sgp_sats[s].elevacion > 0 and sgp_sats[s].elevacion_ant < 0 then
- SF_initTail(s)
- end
- SF_drawSatSky( s )
- end
- SF_drawSatPathSky()
- end
- end
- function SF_procesarConstelaciones(jt)
- if sf_r_pressed and not sf_zoom_mode then
- return
- end
- if sf_sky.show.constellationNames and not sf_l_pressed then
- if not sf_moving_sky then
- SF_calcularConstelaciones(jt)
- end
- SF_dibujarConstelaciones()
- end
- end
- function SF_calcularConstelaciones(jt)
- local c
- for c=1,sgp_constellation_number do
- if sgp_constellations[c].no_calcular > 0 then
- sgp_constellations[c].no_calcular = sgp_constellations[c].no_calcular - 1
- else
- sgp_constellations[c].az, sgp_constellations[c].el = SGP_RADecToAzElev( jt,sgp_constellations[c].label_ra,sgp_constellations[c].label_dec,sgp_location.lat, sgp_location.lon)
- if el < 0 then
- sgp_constellations[c].no_calcular = math.random(50,100)
- end
- end
- end
- end
- function SF_dibujarConstelaciones()
- local c
- for c=1,sgp_constellation_number do
- if sgp_constellations[c].el > 0 then
- SF_drawTextSky(sgp_constellations[c].az , sgp_constellations[c].el ,sgp_constellations[c].nombre, sf_palette[14])
- end
- end
- end
- function SGP_Local_to_UTC(jtime)
- local jt = jtime
- jt = jt - sgp_location.UTC_offset/24.0
- if sgp_time.isdst then --si estamos en horario de verano
- jt = jt - 1.0/24.0
- end
- return jt
- end
- function SGP_UTC_to_Local(jtime)
- local jt = jtime
- jt = jt + (sgp_location.UTC_offset/24.0)
- if sgp_time.isdst then
- jt = jt + (1.0/24.0)
- end
- return jt
- end
- function SF_drawLabelSatsSky(azimut, elevacion, texto, color)
- if elevacion > sf_sky.elevacion_minima then
- local px, py = SF_AzElevToXY( azimut, elevacion )
- if azimut > 90 and azimut < 270 then
- sky:print(px+ 5, py-10, texto, color)
- else
- sky:print(px+ 5, py+2, texto, color)
- end
- end
- end
- function SGP_setLocation(lat, lon, alt, offset, name, dst)
- sgp_location.lat = lat
- sgp_location.lon = lon
- sgp_location.alt = alt
- sgp_location.UTC_offset = offset
- sgp_location.name = name
- sgp_location.dst = dst
- sgp_location.polar.lat = math.rad(sgp_location.lat)
- sgp_location.polar.lon = math.rad(SGP_modulus(sgp_location.lon,360))
- sgp_location.polar.alt = sgp_location.alt * 0.001
- end
- function SGP_initCoefficients()
- sgp_lrCoeff = {}
- sgp_lrCoeff[1] = {0, 0, 1, 0}
- sgp_lrCoeff[2] = {2, 0,-1, 0}
- sgp_lrCoeff[3] = {2, 0, 0, 0}
- sgp_lrCoeff[4] = {0, 0, 2, 0}
- sgp_lrCoeff[5] = {0, 1, 0, 0}
- sgp_lrCoeff[6] = {0, 0, 0, 2}
- sgp_lrCoeff[7] = {2, 0,-2, 0}
- sgp_lrCoeff[8] = {2,-1,-1, 0}
- sgp_lrCoeff[9] = {2, 0, 1, 0}
- sgp_lrCoeff[10] = {2,-1, 0, 0}
- sgp_lrCoeff[11] = {0, 1,-1, 0}
- sgp_lrCoeff[12] = {1, 0, 0, 0}
- sgp_lrCoeff[13] = {0, 1, 1, 0}
- sgp_lrCoeff[14] = {2, 0, 0,-2}
- sgp_lrCoeff[15] = {0, 0, 1, 2}
- sgp_lrCoeff[16] = {0, 0, 1,-2}
- sgp_lrCoeff[17] = {4, 0,-1, 0}
- sgp_lrCoeff[18] = {0, 0, 3, 0}
- sgp_lrCoeff[19] = {4, 0,-2, 0}
- sgp_lrCoeff[20] = {2, 1,-1, 0}
- sgp_lrCoeff[21] = {2, 1, 0, 0}
- sgp_lrCoeff[22] = {1, 0,-1, 0}
- sgp_lrCoeff[23] = {1, 1, 0, 0}
- sgp_lrCoeff[24] = {2,-1, 1, 0}
- sgp_lrCoeff[25] = {2, 0, 2, 0}
- sgp_lrCoeff[26] = {4, 0, 0, 0}
- sgp_lrCoeff[27] = {2, 0,-3, 0}
- sgp_lrCoeff[28] = {0, 1,-2, 0}
- sgp_lrCoeff[29] = {2, 0,-1, 2}
- sgp_lrCoeff[30] = {2,-1,-2, 0}
- sgp_lrCoeff[31] = {1, 0, 1, 0}
- sgp_lrCoeff[32] = {2,-2, 0, 0}
- sgp_lrCoeff[33] = {0, 1, 2, 0}
- sgp_lrCoeff[34] = {0, 2, 0, 0}
- sgp_lrCoeff[35] = {2,-2,-1, 0}
- sgp_lrCoeff[36] = {2, 0, 1,-2}
- sgp_lrCoeff[37] = {2, 0, 0, 2}
- sgp_lrCoeff[38] = {4,-1,-1, 0}
- sgp_lrCoeff[39] = {0, 0, 2, 2}
- sgp_lrCoeff[40] = {3, 0,-1, 0}
- sgp_lrCoeff[41] = {2, 1, 1, 0}
- sgp_lrCoeff[42] = {4,-1,-2, 0}
- sgp_lrCoeff[43] = {0, 2,-1, 0}
- sgp_lrCoeff[44] = {2, 2,-1, 0}
- sgp_lrCoeff[45] = {2, 1,-2, 0}
- sgp_lrCoeff[46] = {2,-1, 0,-2}
- sgp_lrCoeff[47] = {4, 0, 1, 0}
- sgp_lrCoeff[48] = {0, 0, 4, 0}
- sgp_lrCoeff[49] = {4,-1, 0, 0}
- sgp_lrCoeff[50] = {1, 0,-2, 0}
- sgp_lrCoeff[51] = {2, 1, 0,-2}
- sgp_lrCoeff[52] = {0, 0, 2,-2}
- sgp_lrCoeff[53] = {1, 1, 1, 0}
- sgp_lrCoeff[54] = {3, 0,-2, 0}
- sgp_lrCoeff[55] = {4, 0,-3, 0}
- sgp_lrCoeff[56] = {2,-1, 2, 0}
- sgp_lrCoeff[57] = {0, 2, 1, 0}
- sgp_lrCoeff[58] = {1, 1,-1, 0}
- sgp_lrCoeff[59] = {2, 0, 3, 0}
- sgp_lrCoeff[60] = {2, 0,-1,-2}
- sgp_bCoeff = {}
- sgp_bCoeff[1] = {0, 0, 0, 1}
- sgp_bCoeff[2] = {0, 0, 1, 1}
- sgp_bCoeff[3] = {0, 0, 1,-1}
- sgp_bCoeff[4] = {2, 0, 0,-1}
- sgp_bCoeff[5] = {2, 0,-1, 1}
- sgp_bCoeff[6] = {2, 0,-1,-1}
- sgp_bCoeff[7] = {2, 0, 0, 1}
- sgp_bCoeff[8] = {0, 0, 2, 1}
- sgp_bCoeff[9] = {2, 0, 1,-1}
- sgp_bCoeff[10] = {0, 0, 2,-1}
- sgp_bCoeff[11] = {2,-1, 0,-1}
- sgp_bCoeff[12] = {2, 0,-2,-1}
- sgp_bCoeff[13] = {2, 0, 1, 1}
- sgp_bCoeff[14] = {2, 1, 0,-1}
- sgp_bCoeff[15] = {2,-1,-1, 1}
- sgp_bCoeff[16] = {2,-1, 0, 1}
- sgp_bCoeff[17] = {2,-1,-1,-1}
- sgp_bCoeff[18] = {0, 1,-1,-1}
- sgp_bCoeff[19] = {4, 0,-1,-1}
- sgp_bCoeff[20] = {0, 1, 0, 1}
- sgp_bCoeff[21] = {0, 0, 0, 3}
- sgp_bCoeff[22] = {0, 1,-1, 1}
- sgp_bCoeff[23] = {1, 0, 0, 1}
- sgp_bCoeff[24] = {0, 1, 1, 1}
- sgp_bCoeff[25] = {0, 1, 1,-1}
- sgp_bCoeff[26] = {0, 1, 0,-1}
- sgp_bCoeff[27] = {1, 0, 0,-1}
- sgp_bCoeff[28] = {0, 0, 3, 1}
- sgp_bCoeff[29] = {4, 0, 0,-1}
- sgp_bCoeff[30] = {4, 0,-1, 1}
- sgp_bCoeff[31] = {0, 0, 1,-3}
- sgp_bCoeff[32] = {4, 0,-2, 1}
- sgp_bCoeff[33] = {2, 0, 0,-3}
- sgp_bCoeff[34] = {2, 0, 2,-1}
- sgp_bCoeff[35] = {2,-1, 1,-1}
- sgp_bCoeff[36] = {2, 0,-2, 1}
- sgp_bCoeff[37] = {0, 0, 3,-1}
- sgp_bCoeff[38] = {2, 0, 2, 1}
- sgp_bCoeff[39] = {2, 0,-3,-1}
- sgp_bCoeff[40] = {2, 1,-1, 1}
- sgp_bCoeff[41] = {2, 1, 0, 1}
- sgp_bCoeff[42] = {4, 0, 0, 1}
- sgp_bCoeff[43] = {2,-1, 1, 1}
- sgp_bCoeff[44] = {2,-2, 0,-1}
- sgp_bCoeff[45] = {0, 0, 1, 3}
- sgp_bCoeff[46] = {2, 1, 1,-1}
- sgp_bCoeff[47] = {1, 1, 0,-1}
- sgp_bCoeff[48] = {1, 1, 0, 1}
- sgp_bCoeff[49] = {0, 1,-2,-1}
- sgp_bCoeff[50] = {2, 1,-1,-1}
- sgp_bCoeff[51] = {1, 0, 1, 1}
- sgp_bCoeff[52] = {2,-1,-2,-1}
- sgp_bCoeff[53] = {0, 1, 2, 1}
- sgp_bCoeff[54] = {4, 0,-2,-1}
- sgp_bCoeff[55] = {4,-1,-1,-1}
- sgp_bCoeff[56] = {1, 0, 1,-1}
- sgp_bCoeff[57] = {4, 0, 1,-1}
- sgp_bCoeff[58] = {1, 0,-1,-1}
- sgp_bCoeff[59] = {4,-1, 0,-1}
- sgp_bCoeff[60] = {2,-2, 0, 1}
- sgp_lTerms = {
- 6288774,
- 1274027,
- 658314,
- 213618,
- -185116,
- -114332,
- 58793,
- 57066,
- 53322,
- 45758,
- -40923,
- -34720,
- -30383,
- 15327,
- -12528,
- 10980,
- 10675,
- 10034,
- 8548,
- -7888,
- -6766,
- -5163,
- 4987,
- 4036,
- 3994,
- 3861,
- 3665,
- -2689,
- -2602,
- 2390,
- -2348,
- 2236,
- -2120,
- -2069,
- 2048,
- -1773,
- -1595,
- 1215,
- -1110,
- -892,
- -810,
- 759,
- -713,
- -700,
- 691,
- 596,
- 549,
- 537,
- 520,
- -487,
- -399,
- -381,
- 351,
- -340,
- 330,
- 327,
- -323,
- 299,
- 294,
- 0
- }
- sgp_rTerms = {
- -20905355,
- -3699111,
- -2955968,
- -569925,
- 48888,
- -3149,
- 246158,
- -152138,
- -170733,
- -204586,
- -129620,
- 108743,
- 104755,
- 10321,
- 0,
- 79661,
- -34782,
- -23210,
- -21636,
- 24208,
- 30824,
- -8379,
- -16675,
- -12831,
- -10445,
- -11650,
- 14403,
- -7003,
- 0,
- 10056,
- 6322,
- -9884,
- 5751,
- 0,
- -4950,
- 4130,
- 0,
- -3958,
- 0,
- 3258,
- 2616,
- -1897,
- -2117,
- 2354,
- 0,
- 0,
- -1423,
- -1117,
- -1571,
- -1739,
- 0,
- -4421,
- 0,
- 0,
- 0,
- 0,
- 1165,
- 0,
- 0,
- 8752
- }
- sgp_bTerms = {
- 5128122,
- 280602,
- 277693,
- 173237,
- 55413,
- 46271,
- 32573,
- 17198,
- 9266,
- 8822,
- 8216,
- 4324,
- 4200,
- -3359,
- 2463,
- 2211,
- 2065,
- -1870,
- 1828,
- -1794,
- -1749,
- -1565,
- -1491,
- -1475,
- -1410,
- -1344,
- -1335,
- 1107,
- 1021,
- 833,
- 777,
- 671,
- 607,
- 596,
- 491,
- -451,
- 439,
- 422,
- 421,
- -366,
- -351,
- 331,
- 315,
- 302,
- -283,
- -229,
- 223,
- 223,
- -220,
- -220,
- -185,
- 181,
- -177,
- 176,
- 166,
- -164,
- 132,
- -119,
- 115,
- 107
- }
- end
- function SF_readInput()
- if sf_primer_calculo then
- sf_entrada = nil
- sf_entrada_ant = Controls.read()
- sf_acel_x = 0
- sf_acel_y = 0
- sf_moving_sky = false
- else
- sf_entrada = Controls.read()
- sf_analog_x = sf_entrada:analogX()
- sf_analog_y = sf_entrada:analogY()
- if sf_analog_x > 30 or sf_analog_x < -30 or sf_analog_y > 30 or sf_analog_y < -30 then
- sf_acel_x = sf_acel_x + sf_analog_x * 0.01
- sf_acel_y = sf_acel_y - sf_analog_y * 0.01
- sf_star_update_current_rate = 1
- sf_moving_sky = true
- else
- sf_acel_x = sf_acel_x * 0.5
- sf_acel_y = sf_acel_y * 0.5
- if math.abs(sf_acel_x) < 0.1 and math.abs(sf_acel_y) < 0.1 then
- sf_acel_x = 0
- sf_acel_y = 0
- sf_moving_sky = false
- end
- end
- if sf_r_pressed and sf_zoom_mode then
- sf_sky.rotacion = sf_sky.rotacion - sf_acel_x * sf_sky.orientacion
- if sf_sky.rotacion > 360 then
- sf_sky.rotacion = sf_sky.rotacion - 360
- end
- if sf_sky.rotacion < 0 then
- sf_sky.rotacion = sf_sky.rotacion + 360
- end
- elseif sf_zoom_mode then
- local total = sf_acel_x + sf_acel_y
- sf_sky.radio = sf_sky.radio + total
- if sf_sky.radio < 130 then
- sf_sky.radio = 130
- end
- sf_sky.centro.x = sf_sky.centro.x + ((sf_sky.centro.x - 240)*((sf_sky.radio/(sf_sky.radio - total))-1))
- sf_sky.centro.y = sf_sky.centro.y + ((sf_sky.centro.y - 136)*((sf_sky.radio/(sf_sky.radio - total))-1))
- local distancia = math.sqrt( ((sf_sky.centro.x - 240)*(sf_sky.centro.x - 240)) + ((sf_sky.centro.y - 136)*(sf_sky.centro.y - 136)) )
- if distancia > sf_sky.radio then
- sf_sky.centro.x = sf_sky.centro.x - ((sf_sky.centro.x - 240)*((sf_sky.radio/(sf_sky.radio - total))-1))
- sf_sky.centro.y = sf_sky.centro.y - ((sf_sky.centro.y - 136)*((sf_sky.radio/(sf_sky.radio - total))-1))
- end
- else
- sf_sky.centro.x = sf_sky.centro.x - sf_acel_x
- sf_sky.centro.y = sf_sky.centro.y + sf_acel_y
- local distancia = math.sqrt( ((sf_sky.centro.x - 240)*(sf_sky.centro.x - 240)) + ((sf_sky.centro.y - 136)*(sf_sky.centro.y - 136)) )
- if distancia > sf_sky.radio then
- sf_acel_x = -sf_acel_x
- sf_acel_y = -sf_acel_y
- end
- end
- if sf_entrada == sf_entrada_ant then
- return
- end
- sf_zoom_mode = false
- --L y R
- sf_r_pressed = sf_entrada:r()
- sf_l_pressed = sf_entrada:l()
- -- CRUZ
- if sf_entrada:cross() then
- sf_entrada_ant = sf_entrada
- SF_drawAllNextVisiblePassList()
- -- CIRCULO
- elseif sf_entrada:circle() then
- sf_entrada_ant = sf_entrada
- if sf_vision_nocturna then
- sf_vision_nocturna = false
- SF_changePalette (sf_color_day.r,sf_color_day.g,sf_color_day.b)
- else
- sf_vision_nocturna = true
- SF_changePalette (sf_color_night.r,sf_color_night.g,sf_color_night.b)
- end
- --TRIANGULO
- elseif sf_entrada:triangle() then
- sf_entrada_ant = sf_entrada
- if sf_iss ~= nil then
- SF_drawSatNextVisiblePassList(sf_iss)
- end
- --CUADRADO
- elseif sf_entrada:square() then
- sf_entrada_ant = sf_entrada
- sf_zoom_mode = true
- elseif sf_entrada:up() then
- if sgp_mag_limit + 0.2 <= sgp_mag_max + 0.1 then
- sgp_mag_limit = sgp_mag_limit + 0.2
- end
- elseif sf_entrada:down() then
- if sgp_mag_limit - 0.2 >= -2.1 then
- sgp_mag_limit = sgp_mag_limit - 0.2
- end
- elseif sf_entrada:left() then
- if sf_sky.orientacion < 0 then
- sf_sky.orientacion = 1.0
- else
- sf_sky.orientacion = -1.0
- end
- elseif sf_entrada:right() then
- if sf_sky.orientacion < 0 then
- sf_sky.orientacion = 1.0
- else
- sf_sky.orientacion = -1.0
- end
- -- elseif sf_entrada:hold() then
- -- elseif sf_entrada:note() then
- elseif sf_entrada:select() then
- SF_downloadTLEs()
- sgp_sat_number = 0 -- esta variable tiene que ser cero y se modifica por SGP_getTLE()
- SGP_getTLE("./tle/visual.tle")
- SGP_getTLE("./tle/iridium.tle")
- SF_initTails()
- if sgp_sat_number == -1 then
- screen.print(30, 150, "Error: Archivos TLE corruptos." , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(30, 150, "Error: Archivos TLE corruptos." , sf_palette[1])
- screen.waitvblankstart(300)
- screen.flip()
- sgp_sat_number = 0
- else
- screen.print(30, 150, "OK! (".. sgp_sat_number..")" , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(30, 150, "OK! (".. sgp_sat_number.." satelites)" , sf_palette[1])
- screen.waitvblankstart(200)
- screen.flip()
- end
- -- elseif entrada:home() then
- elseif sf_entrada:start() then
- SF_cambiarConfiguracion()
- elseif sf_l_pressed and sf_r_pressed then
- SF_screenshot()
- end
- sf_entrada_ant = sf_entrada
- end
- end
- function SF_screenshot()
- screen.toimage():save("../../../../PICTURE/captura_"..sgp_time.year.."_"..sgp_time.month.."_".. sgp_time.day.."_".. sgp_time.hour.."_".. sgp_time.min.."_".. sgp_time.sec..".png")
- SF_erase (0,262,80)
- screen.print(0, 262, "Screenshot saved in a PNG file.", sf_color_white)
- screen.waitvblankstart()
- screen.flip()
- screen.waitvblankstart(200)
- end
- function SF_constants()
- const_xmnpda = 1440.0
- -- Constante gravitacional de la tierra
- const_ge = 398600.8
- const_ae = 1.0
- const_tothrd = 2.0/3.0
- -- Radio ecuatorial de la tierra en kilómetros
- const_xkmper = 6378.135
- -- Achatamiento de la tierra
- const_f = 1.0/298.26
- -- Armónico J2
- const_J2 = 1.0826158e-3
- -- Armónico J3
- const_J3 = -2.53881e-6
- -- Armónico J4
- const_J4 = -1.65597e-6
- const_ck2 = const_J2/2.0
- const_ck4 = -3.0*const_J4/8.0
- const_xj3 = const_J3
- const_qo = const_ae + (120.0/const_xkmper)
- const_s = const_ae + (78/const_xkmper)
- const_e6a = 0.000001
- -- Código de inialización del modelo Deep-Space
- const_dpinit = 1
- -- Código secular del modelo Deep-Space
- const_dpsec = 2
- -- Código periódico del modelo Deep-Space
- const_dpper = 3
- -- Radio solar en kilómetros
- const_sr = 696000.0
- -- Unidad Astronómica (distancia de la Tierra al Sol en kilómetros)
- const_AU = 1.49597870e8
- -- Minutos por dia
- const_xmnpda = 1440.0
- -- Segundos por dia
- const_secday = 86400.0
- -- Rotaciones de la tierra por día sideral (no-constante)
- const_omega_E = 1.00273790934
- -- Rotacion de la tierra, radianes por dia sideral
- const_omega_ER = const_omega_E*(math.pi*2.0)
- -- Sqrt(ge) ER^3/min^2
- const_xke = math.sqrt(3600.0*const_ge/(const_xkmper^3))
- -- (qo-s)^4 ER^4
- const_qoms2t = (const_qo-const_s)^4
- -- Twilight elevations
- const_twilightCivil = -6
- const_twilightNautical = -12
- const_twilightAstronomical = -18
- const_mfactor = (math.pi*2.0)*const_omega_E/const_secday
- const_julian_minute = 0.000694446
- --Constantes para calcular la posicion de la luna
- const_epoch = 2444238.5 --1980 January 0.0
- --Constants defining the Sun's apparent orbit
- const_elonge = 278.833540 --Ecliptic longitude of the Sun at epoch 1980.0
- const_elongp = 282.596403 --Ecliptic longitude of the Sun at perigee
- const_eccent = 0.016718 --Eccentricity of Earth's orbit
- const_sunangsiz = 0.533128 --Sun's angular size, degrees, at semi-major axis distance
- const_AstronomicalUnit = 149597870.0 -- Astronomical unit in kilometres
- const_SunSMAX = (const_AstronomicalUnit * 1.000001018) -- Semi-major axis of Earth's orbit
- --Elements of the Moon's orbit, epoch 1980.0
- const_mmlong = 64.975464 --Moon's mean longitude at the epoch
- const_mmlongp = 349.383063 --Mean longitude of the perigee at the epoch
- const_mlnode = 151.950429 --Mean longitude of the node at the epoch
- const_minc = 5.145396 --Inclination of the Moon's orbit
- const_mecc = 0.054900 --Eccentricity of the Moon's orbit
- const_mangsiz = 0.5181 --Moon's angular size at distance a from Earth
- const_msmax = 384401.0 --Semi-major axis of Moon's orbit in km
- const_mparallax = 0.9507 --Parallax at distance a from Earth
- const_SynMonth = 29.53058868
- const_JulianCentury = 36525.0 -- Days in Julian century
- const_J2000 = 2451545.0
- const_NTERMS = 60
- end
- function SF_loadConfigFromFile(filename)
- -- Miramos primero que el fichero exista
- local file = io.open(filename)
- if file then
- io.close(file)
- else
- return false
- end
- for line in io.lines(filename) do
- local c = string.find(line," ",1,true)
- local str = string.sub(line,1,c-1)
- if str == "sun_and_moon" then
- sf_sky.show.sunAndMoon = (string.sub(line,c+1,string.len(line)) == "true")
- elseif str == "satellites" then
- sf_sky.show.satellites = (string.sub(line,c+1,string.len(line)) == "true")
- elseif str == "stars" then
- sf_sky.show.stars = (string.sub(line,c+1,string.len(line)) == "true")
- elseif str == "auto_magnitude" then
- sf_sky.show.autoMagStars = (string.sub(line,c+1,string.len(line)) == "true")
- elseif str == "satellite_names" then
- sf_sky.show.satelliteNames = (string.sub(line,c+1,string.len(line)) == "true")
- elseif str == "constellation_names" then
- sf_sky.show.constellationNames = (string.sub(line,c+1,string.len(line)) == "true")
- elseif str == "elevation_lines" then
- sf_sky.show.elevationLines = (string.sub(line,c+1,string.len(line)) == "true")
- elseif str == "color_day_r" then
- sf_color_day.r = tonumber(string.sub(line,c+1,string.len(line)))
- elseif str == "color_day_g" then
- sf_color_day.g = tonumber(string.sub(line,c+1,string.len(line)))
- elseif str == "color_day_b" then
- sf_color_day.b = tonumber(string.sub(line,c+1,string.len(line)))
- elseif str == "color_night_r" then
- sf_color_night.r = tonumber(string.sub(line,c+1,string.len(line)))
- elseif str == "color_night_g" then
- sf_color_night.g = tonumber(string.sub(line,c+1,string.len(line)))
- elseif str == "color_night_b" then
- sf_color_night.b = tonumber(string.sub(line,c+1,string.len(line)))
- end
- end
- return true
- end
- function SF_saveConfigToFile ( filename )
- local f = io.open (filename, "w+")
- if sf_sky.show.sunAndMoon then
- f:write("sun_and_moon true\n")
- else
- f:write("sun_and_moon false\n")
- end
- if sf_sky.show.satellites then
- f:write("satellites true\n" )
- else
- f:write("satellites false\n")
- end
- if sf_sky.show.stars then
- f:write("stars true\n" )
- else
- f:write("stars false\n")
- end
- if sf_sky.show.autoMagStars then
- f:write("auto_magnitude true\n")
- else
- f:write("auto_magnitude false\n")
- end
- if sf_sky.show.satelliteNames then
- f:write("satellite_names true\n" )
- else
- f:write("satellite_names false\n")
- end
- if sf_sky.show.constellationNames then
- f:write("constellation_names true\n" )
- else
- f:write("constellation_names false\n")
- end
- if sf_sky.show.elevationLines then
- f:write("elevation_lines true\n" )
- else
- f:write("elevation_lines false\n")
- end
- f:write("color_day_r "..sf_color_day.r .. "\n")
- f:write("color_day_g "..sf_color_day.g .. "\n")
- f:write("color_day_b "..sf_color_day.b .. "\n")
- f:write("color_night_r "..sf_color_night.r .. "\n")
- f:write("color_night_g "..sf_color_night.g .. "\n")
- f:write("color_night_b "..sf_color_night.b .. "\n")
- f:flush()
- io.close(f)
- end
- function SF_cambiarConfiguracion()
- local linea = 1
- local opciones = 15
- local changed = false
- local current_lat, current_lon, current_alt
- local NS, EW
- if sgp_location.lat >= 0 then
- current_lat = string.format ("%.2f",sgp_location.lat)
- NS = "N"
- else
- current_lat = string.format ("%.2f",sgp_location.lat*-1)
- NS = "S"
- end
- if sgp_location.lat < 10.0 and sgp_location.lat > -10.0 then
- current_lat = "0" .. current_lat
- end
- if sgp_location.lon >= 0 then
- current_lon = string.format ("%.2f",sgp_location.lon)
- EW = "E"
- else
- current_lon = string.format ("%.2f",sgp_location.lon*-1)
- EW = "W"
- end
- if sgp_location.lon < 100.0 and sgp_location.lon > -100.0 then
- current_lon = "0" .. current_lon
- end
- if sgp_location.lon < 10.0 and sgp_location.lon > -10.0 then
- current_lon = "0" .. current_lon
- end
- current_alt = string.format ("%04d",sgp_location.alt)
- current_UTC_offset = "GMT" .. string.format ("%+03d",sgp_location.UTC_offset)
- current_name = sgp_location.name
- local pintar_cursor = true
- local cursor_x = 428
- repeat
- screen.clear(sf_sky_color)
- screen.print(1,1,"----- OPCIONES ------------------------------------------------------", sf_palette[1])
- SF_drawInfoBar(false)
- screen.print(1,11, "Elementos del cielo disponibles:" , sf_palette[8])
- screen.print(1, 21, " - Sol y Luna" , sf_palette[4])
- if sf_sky.show.sunAndMoon then
- screen.print(420, 21, "[x]" , sf_palette[4])
- else
- screen.print(420, 21, "[ ]" , sf_palette[4])
- end
- screen.print(1,31, " - Satelites" , sf_palette[4])
- if sf_sky.show.satellites then
- screen.print(420, 31, "[x]" , sf_palette[4])
- else
- screen.print(420, 31, "[ ]" , sf_palette[4])
- end
- screen.print(1,41, " - Estrellas" , sf_palette[4])
- if sf_sky.show.stars then
- screen.print(420, 41, "[x]" , sf_palette[4])
- else
- screen.print(420, 41, "[ ]" , sf_palette[4])
- end
- screen.print(1,51, " - Magnitud de estrellas automatico" , sf_palette[4])
- if sf_sky.show.autoMagStars then
- screen.print(420, 51, "[x]" , sf_palette[4])
- else
- screen.print(420, 51, "[ ]" , sf_palette[4])
- end
- screen.print(1,61, " - Nombre de los satelites" , sf_palette[4])
- if sf_sky.show.satelliteNames then
- screen.print(420, 61, "[x]" , sf_palette[4])
- else
- screen.print(420, 61, "[ ]" , sf_palette[4])
- end
- screen.print(1, 71, " - Nombre de las constelaciones" , sf_palette[4])
- if sf_sky.show.constellationNames then
- screen.print(420, 71, "[x]" , sf_palette[4])
- else
- screen.print(420, 71, "[ ]" , sf_palette[4])
- end
- screen.print(1, 81, " - Lineas de referencia en 30, 60 y 90 grados" , sf_palette[4])
- if sf_sky.show.elevationLines then
- screen.print(420, 81, "[x]" , sf_palette[4])
- else
- screen.print(420, 81, "[ ]" , sf_palette[4])
- end
- screen.print(1, 91, "Coordenadas de localizacion:" , sf_palette[8])
- screen.print(1, 101, " - Latitud", sf_palette[4])
- screen.print(380, 101, "[" .. current_lat .. NS .. "]", sf_palette[4])
- screen.print(1, 111, " - Longitud", sf_palette[4])
- screen.print(372, 111, "[" .. current_lon .. EW .. "]", sf_palette[4])
- screen.print(1, 121, " - Altitud (en metros)", sf_palette[4])
- screen.print(396, 121, "[" .. current_alt .. "]" , sf_palette[4])
- screen.print(1, 131, " - Zona horaria", sf_palette[4])
- screen.print(380, 131, "[" .. current_UTC_offset .. "]" , sf_palette[4])
- screen.print(1, 141, "Colores de dia y noche:" , sf_palette[8])
- screen.print(1, 151, " - Dia:",sf_palette[4])
- screen.print(124, 151, "Rojo ["..string.format ("%03d",sf_color_day.r).."] Verde ["..string.format ("%03d",sf_color_day.g).."] Azul ["..string.format ("%03d",sf_color_day.b).."]", sf_palette[4])
- screen.print(1, 161, " - Noche:",sf_palette[4])
- screen.print(124, 161, "Rojo ["..string.format ("%03d",sf_color_night.r).."] Verde ["..string.format ("%03d",sf_color_night.g).."] Azul ["..string.format ("%03d",sf_color_night.b).."]", sf_palette[4])
- screen.print(1, 251, "Pulsa X para modificar la opcion seleccionada.", sf_palette[8])
- screen.print(1, 261, "Pulsa O para salir de las opciones.", sf_palette[8])
- if pintar_cursor then
- screen.print(cursor_x,13 + 10 * linea, "_", sf_palette[1])
- pintar_cursor = false
- else
- pintar_cursor = true
- end
- screen.waitvblankstart()
- screen.flip()
- sf_entrada = Controls.read()
- if sf_entrada:up() then
- if linea > 1 then
- linea = linea - 1
- if linea == 8 then
- linea = linea - 1
- end
- end
- pintar_cursor = true
- elseif sf_entrada:down() then
- if linea < opciones then
- linea = linea + 1
- if linea == 8 then
- linea = linea + 1
- elseif linea == 13 then
- linea = linea + 1
- end
- end
- pintar_cursor = true
- elseif sf_entrada ~= sf_entrada_ant then
- sf_entrada_ant = sf_entrada
- if sf_entrada:cross() then
- if linea == 1 then
- sf_sky.show.sunAndMoon = not sf_sky.show.sunAndMoon
- elseif linea == 2 then
- sf_sky.show.satellites = not sf_sky.show.satellites
- elseif linea == 3 then
- sf_sky.show.stars = not sf_sky.show.stars
- elseif linea == 4 then
- sf_sky.show.autoMagStars = not sf_sky.show.autoMagStars
- elseif linea == 5 then
- sf_sky.show.satelliteNames = not sf_sky.show.satelliteNames
- elseif linea == 6 then
- sf_sky.show.constellationNames = not sf_sky.show.constellationNames
- elseif linea == 7 then
- sf_sky.show.elevationLines = not sf_sky.show.elevationLines
- elseif linea == 9 then
- SF_editLatitud()
- if sgp_location.lat >= 0 then
- current_lat = string.format ("%.2f",sgp_location.lat)
- NS = "N"
- else
- current_lat = string.format ("%.2f",sgp_location.lat*-1)
- NS = "S"
- end
- if sgp_location.lat < 10.0 and sgp_location.lat > -10.0 then
- current_lat = "0" .. current_lat
- end
- changed = true
- elseif linea == 10 then
- SF_editLongitud()
- if sgp_location.lon >= 0 then
- current_lon = string.format ("%.2f",sgp_location.lon)
- EW = "E"
- else
- current_lon = string.format ("%.2f",sgp_location.lon*-1)
- EW = "W"
- end
- if sgp_location.lon < 100.0 and sgp_location.lon > -100.0 then
- current_lon = "0" .. current_lon
- end
- if sgp_location.lon < 10.0 and sgp_location.lon > -10.0 then
- current_lon = "0" .. current_lon
- end
- changed = true
- elseif linea == 11 then
- SF_editAltitud()
- current_alt = string.format ("%04d",sgp_location.alt)
- changed = true
- elseif linea == 12 then
- SF_editUtcOffset()
- current_UTC_offset = "GMT" .. string.format ("%+03d",sgp_location.UTC_offset)
- changed = true
- elseif linea == 14 then
- SF_editColorDay()
- if sf_vision_nocturna then
- SF_changePalette (sf_color_night.r,sf_color_night.g,sf_color_night.b)
- else
- SF_changePalette (sf_color_day.r,sf_color_day.g,sf_color_day.b)
- end
- elseif linea == 15 then
- SF_editColorNight()
- if sf_vision_nocturna then
- SF_changePalette (sf_color_night.r,sf_color_night.g,sf_color_night.b)
- else
- SF_changePalette (sf_color_day.r,sf_color_day.g,sf_color_day.b)
- end
- end
- end
- end
- sf_entrada_ant = sf_entrada
- screen.waitvblankstart(10)
- until sf_entrada:circle()
- if changed then
- SF_initTails()
- SF_enableAllSatellites()
- SF_enableAllStars()
- sgp_location.name = "Personalizado"
- sgp_location.polar.lat = math.rad(sgp_location.lat)
- sgp_location.polar.lon = math.rad(SGP_modulus(sgp_location.lon,360))
- sgp_location.polar.alt = sgp_location.alt * 0.001
- end
- SF_saveConfigToFile ("config.txt")
- end
- function SF_editLatitud()
- local current_lat
- local NS
- if sgp_location.lat >= 0 then
- current_lat = string.format ("%.2f",sgp_location.lat)
- NS = "N"
- else
- current_lat = string.format ("%.2f",sgp_location.lat*-1)
- NS = "S"
- end
- if sgp_location.lat < 10.0 and sgp_location.lat > -10.0 then
- current_lat = "0" .. current_lat
- end
- --Edicion latitud
- local edit_x, edit_y, edit_pos, edit_len
- edit_x = 388
- edit_y = 101
- edit_pos = 1
- edit_len = 6
- local lat = { }
- lat[1] = string.sub(current_lat,1,1)
- lat[2] = string.sub(current_lat,2,2)
- lat[3] = string.sub(current_lat,3,3)
- lat[4] = string.sub(current_lat,4,4)
- lat[5] = string.sub(current_lat,5,5)
- lat[6] = NS
- local pintar_cursor = true
- while true do
- draw.fillrect(edit_x, edit_y, edit_len * 8 , 9, sf_color_black)
- screen.print(edit_x, edit_y, lat[1] .. lat[2] .. lat[3] .. lat[4] .. lat[5] .. lat[6] .. "]",sf_palette[1])
- if pintar_cursor then
- screen.print(edit_x + (edit_pos-1) * 8,edit_y + 2, "_", sf_palette[1])
- pintar_cursor = false
- else
- pintar_cursor = true
- end
- screen.waitvblankstart()
- screen.flip()
- sf_entrada = Controls.read()
- if sf_entrada:right() then
- if edit_pos < edit_len then
- edit_pos = edit_pos + 1
- end
- pintar_cursor = true
- elseif sf_entrada:left() then
- if edit_pos > 1 then
- edit_pos = edit_pos - 1
- end
- pintar_cursor = true
- elseif sf_entrada:up() then
- if edit_pos == 1 or edit_pos == 2 or edit_pos == 4 or edit_pos == 5 then
- if tonumber(lat[edit_pos]) < 9 then
- lat[edit_pos] = lat[edit_pos] + 1
- end
- elseif edit_pos == 6 then
- lat[edit_pos] = "N"
- end
- pintar_cursor = true
- elseif sf_entrada:down() then
- if edit_pos == 1 or edit_pos == 2 or edit_pos == 4 or edit_pos == 5 then
- if tonumber(lat[edit_pos]) > 0 then
- lat[edit_pos] = lat[edit_pos] - 1
- end
- elseif edit_pos == 6 then
- lat[edit_pos] = "S"
- end
- pintar_cursor = true
- elseif sf_entrada ~= sf_entrada_ant then
- sf_entrada_ant = sf_entrada
- if sf_entrada:cross() then
- if lat[6] == "N" then
- sgp_location.lat = tonumber(lat[1]..lat[2]..lat[3]..lat[4]..lat[5])
- else
- sgp_location.lat = -tonumber(lat[1]..lat[2]..lat[3]..lat[4]..lat[5])
- end
- return
- end
- end
- if lat[1] == 9 then
- lat[2] = 0
- lat[4] = 0
- lat[5] = 0
- end
- sf_entrada_ant = sf_entrada
- screen.waitvblankstart(10)
- end
- end
- function SF_editLongitud()
- if sgp_location.lon >= 0 then
- current_lon = string.format ("%.2f",sgp_location.lon)
- EW = "E"
- else
- current_lon = string.format ("%.2f",sgp_location.lon*-1)
- EW = "W"
- end
- if sgp_location.lon < 100.0 and sgp_location.lon > -100.0 then
- current_lon = "0" .. current_lon
- end
- if sgp_location.lon < 10.0 and sgp_location.lon > -10.0 then
- current_lon = "0" .. current_lon
- end
- --Edicion longitud
- edit_x = 380
- edit_y = 111
- edit_pos = 1
- edit_len = 7
- local lon = { }
- lon[1] = string.sub(current_lon,1,1)
- lon[2] = string.sub(current_lon,2,2)
- lon[3] = string.sub(current_lon,3,3)
- lon[4] = string.sub(current_lon,4,4)
- lon[5] = string.sub(current_lon,5,5)
- lon[6] = string.sub(current_lon,6,6)
- lon[7] = EW
- pintar_cursor = true
- while true do
- draw.fillrect(edit_x, edit_y, edit_len * 8 , 9, sf_color_black)
- screen.print(edit_x, edit_y, lon[1] .. lon[2] .. lon[3] .. lon[4] .. lon[5] .. lon[6] .. lon[7] .. "]",sf_palette[1])
- if pintar_cursor then
- screen.print(edit_x + (edit_pos-1) * 8,edit_y + 2, "_", sf_palette[1])
- pintar_cursor = false
- else
- pintar_cursor = true
- end
- screen.waitvblankstart()
- screen.flip()
- local sf_entrada = Controls.read()
- if sf_entrada:right() then
- if edit_pos < edit_len then
- edit_pos = edit_pos + 1
- end
- pintar_cursor = true
- elseif sf_entrada:left() then
- if edit_pos > 1 then
- edit_pos = edit_pos - 1
- end
- pintar_cursor = true
- elseif sf_entrada:up() then
- if edit_pos == 1 or edit_pos == 2 or edit_pos == 3 or edit_pos == 5 or edit_pos == 6 then
- if tonumber(lon[edit_pos]) < 9 then
- lon[edit_pos] = lon[edit_pos] + 1
- end
- elseif edit_pos == 7 then
- lon[edit_pos] = "E"
- end
- pintar_cursor = true
- elseif sf_entrada:down() then
- if edit_pos == 1 or edit_pos == 2 or edit_pos == 3 or edit_pos == 5 or edit_pos == 6 then
- if tonumber(lon[edit_pos]) > 0 then
- lon[edit_pos] = lon[edit_pos] - 1
- end
- elseif edit_pos == 7 then
- lon[edit_pos] = "W"
- end
- pintar_cursor = true
- elseif sf_entrada ~= sf_entrada_ant then
- sf_entrada_ant = sf_entrada
- if sf_entrada:cross() then
- if lon[7] == "E" then
- sgp_location.lon = tonumber(lon[1]..lon[2]..lon[3]..lon[4]..lon[5]..lon[6])
- else
- sgp_location.lon = tonumber(lon[1]..lon[2]..lon[3]..lon[4]..lon[5]..lon[6])*-1
- end
- return
- end
- end
- if tonumber(lon[1]) > 1 then
- lon[1] = 1
- lon[2] = 8
- lon[3] = 0
- lon[5] = 0
- lon[6] = 0
- elseif tonumber(lon[1]) == 1 and tonumber(lon[2]) > 8 then
- lon[2] = 8
- lon[3] = 0
- lon[5] = 0
- lon[6] = 0
- elseif tonumber(lon[1]) == 1 and tonumber(lon[2]) == 8 then
- lon[3] = 0
- lon[5] = 0
- lon[6] = 0
- end
- sf_entrada_ant = sf_entrada
- screen.waitvblankstart(10)
- end
- end
- function SF_editAltitud ()
- current_alt = string.format ("%04d",sgp_location.alt)
- --Edicion altitud
- edit_x = 404
- edit_y = 121
- edit_pos = 1
- edit_len = 4
- local alt = { }
- alt[1] = string.sub(current_alt,1,1)
- alt[2] = string.sub(current_alt,2,2)
- alt[3] = string.sub(current_alt,3,3)
- alt[4] = string.sub(current_alt,4,4)
- pintar_cursor = true
- while true do
- draw.fillrect(edit_x, edit_y, edit_len * 8 , 9, sf_color_black)
- screen.print(edit_x, edit_y, alt[1] .. alt[2] .. alt[3] .. alt[4],sf_palette[1])
- if pintar_cursor then
- screen.print(edit_x + (edit_pos-1) * 8,edit_y + 2, "_", sf_palette[1])
- pintar_cursor = false
- else
- pintar_cursor = true
- end
- screen.waitvblankstart()
- screen.flip()
- sf_entrada = Controls.read()
- if sf_entrada:right() then
- if edit_pos < edit_len then
- edit_pos = edit_pos + 1
- end
- pintar_cursor = true
- elseif sf_entrada:left() then
- if edit_pos > 1 then
- edit_pos = edit_pos - 1
- end
- pintar_cursor = true
- elseif sf_entrada:up() then
- if tonumber(alt[edit_pos]) < 9 then
- alt[edit_pos] = alt[edit_pos] + 1
- end
- pintar_cursor = true
- elseif sf_entrada:down() then
- if tonumber(alt[edit_pos]) > 0 then
- alt[edit_pos] = alt[edit_pos] - 1
- end
- pintar_cursor = true
- elseif sf_entrada ~= sf_entrada_ant then
- sf_entrada_ant = sf_entrada
- if sf_entrada:cross() then
- sgp_location.alt = tonumber(alt[1]..alt[2]..alt[3]..alt[4])
- return
- end
- end
- sf_entrada_ant = sf_entrada
- screen.waitvblankstart(10)
- end
- end
- function SF_editUtcOffset()
- current_UTC_offset = "GMT" .. string.format ("%+03d",sgp_location.UTC_offset)
- --Edicion UTC Offset
- edit_x = 388
- edit_y = 131
- edit_pos = 4
- edit_len = 6
- local utc_off = sgp_location.UTC_offset
- pintar_cursor = true
- while true do
- draw.fillrect(edit_x, edit_y, edit_len * 8 , 9, sf_color_black)
- screen.print(edit_x, edit_y, "GMT" .. string.format ("%+03d",utc_off),sf_palette[1])
- if pintar_cursor then
- screen.print(edit_x + (edit_pos-1) * 8,edit_y + 2, "___", sf_palette[1])
- pintar_cursor = false
- else
- pintar_cursor = true
- end
- screen.waitvblankstart()
- screen.flip()
- local sf_entrada = Controls.read()
- if sf_entrada:up() then
- if utc_off < 12 then
- utc_off = utc_off + 1
- end
- elseif sf_entrada:down() then
- if utc_off > -12 then
- utc_off = utc_off - 1
- end
- elseif sf_entrada ~= sf_entrada_ant then
- sf_entrada_ant = sf_entrada
- if sf_entrada:cross() then
- sgp_location.UTC_offset = utc_off
- return
- end
- end
- sf_entrada_ant = sf_entrada
- screen.waitvblankstart(10)
- end
- end
- function SF_editColorDay()
- --Edicion UTC Offset
- edit_x = 172
- edit_y = 151
- edit_pos = 2
- edit_len = 3
- edit_rgb = 1
- pintar_cursor = true
- while true do
- local edit_color = color.new(sf_color_day.r,sf_color_day.g,sf_color_day.b)
- draw.fillrect(edit_x, edit_y, edit_len * 8 , 9, sf_color_black)
- screen.print(edit_x, edit_y, string.format ("%03d",sf_color_day.r),edit_color)
- draw.fillrect(edit_x + 120, edit_y, edit_len * 8 , 9, sf_color_black)
- screen.print(edit_x+ 120, edit_y, string.format ("%03d",sf_color_day.g),edit_color)
- draw.fillrect(edit_x+ 240, edit_y, edit_len * 8 , 9, sf_color_black)
- screen.print(edit_x+ 240, edit_y, string.format ("%03d",sf_color_day.b),edit_color)
- if pintar_cursor then
- screen.print(edit_x + (edit_pos-2) * 8 + (edit_rgb-1)*120 ,edit_y + 2, "___", sf_palette[1])
- pintar_cursor = false
- else
- pintar_cursor = true
- end
- screen.waitvblankstart()
- screen.flip()
- local sf_entrada = Controls.read()
- if sf_entrada:up() then
- if edit_rgb == 1 then
- if sf_color_day.r + 5 <= 255 then
- sf_color_day.r = sf_color_day.r + 5
- end
- elseif edit_rgb == 2 then
- if sf_color_day.g + 5 <= 255 then
- sf_color_day.g = sf_color_day.g + 5
- end
- elseif edit_rgb == 3 then
- if sf_color_day.b + 5 <= 255 then
- sf_color_day.b = sf_color_day.b + 5
- end
- end
- elseif sf_entrada:down() then
- if edit_rgb == 1 then
- if sf_color_day.r - 5 >= 0 then
- sf_color_day.r = sf_color_day.r - 5
- end
- elseif edit_rgb == 2 then
- if sf_color_day.g - 5 >= 0 then
- sf_color_day.g = sf_color_day.g - 5
- end
- elseif edit_rgb == 3 then
- if sf_color_day.b - 5 >= 0 then
- sf_color_day.b = sf_color_day.b - 5
- end
- end
- elseif sf_entrada ~= sf_entrada_ant then
- sf_entrada_ant = sf_entrada
- if sf_entrada:left() then
- if edit_rgb > 1 then
- edit_rgb = edit_rgb - 1
- end
- elseif sf_entrada:right() then
- if edit_rgb < 3 then
- edit_rgb = edit_rgb + 1
- end
- elseif sf_entrada:cross() then
- return
- end
- end
- sf_entrada_ant = sf_entrada
- screen.waitvblankstart(10)
- end
- end
- function SF_editColorNight()
- --Edicion UTC Offset
- edit_x = 172
- edit_y = 161
- edit_pos = 2
- edit_len = 3
- edit_rgb = 1
- pintar_cursor = true
- while true do
- local edit_color = color.new(sf_color_night.r,sf_color_night.g,sf_color_night.b)
- draw.fillrect(edit_x, edit_y, edit_len * 8 , 9, sf_color_black)
- screen.print(edit_x, edit_y, string.format ("%03d",sf_color_night.r),edit_color)
- draw.fillrect(edit_x + 120, edit_y, edit_len * 8 , 9, sf_color_black)
- screen.print(edit_x+ 120, edit_y, string.format ("%03d",sf_color_night.g),edit_color)
- draw.fillrect(edit_x+ 240, edit_y, edit_len * 8 , 9, sf_color_black)
- screen.print(edit_x+ 240, edit_y, string.format ("%03d",sf_color_night.b),edit_color)
- if pintar_cursor then
- screen.print(edit_x + (edit_pos-2) * 8 + (edit_rgb-1)*120 ,edit_y + 2, "___", sf_palette[1])
- pintar_cursor = false
- else
- pintar_cursor = true
- end
- screen.waitvblankstart()
- screen.flip()
- local sf_entrada = Controls.read()
- if sf_entrada:up() then
- if edit_rgb == 1 then
- if sf_color_night.r + 5 <= 255 then
- sf_color_night.r = sf_color_night.r + 5
- end
- elseif edit_rgb == 2 then
- if sf_color_night.g + 5 <= 255 then
- sf_color_night.g = sf_color_night.g + 5
- end
- elseif edit_rgb == 3 then
- if sf_color_night.b + 5 <= 255 then
- sf_color_night.b = sf_color_night.b + 5
- end
- end
- elseif sf_entrada:down() then
- if edit_rgb == 1 then
- if sf_color_night.r - 5 >= 0 then
- sf_color_night.r = sf_color_night.r - 5
- end
- elseif edit_rgb == 2 then
- if sf_color_night.g - 5 >= 0 then
- sf_color_night.g = sf_color_night.g - 5
- end
- elseif edit_rgb == 3 then
- if sf_color_night.b - 5 >= 0 then
- sf_color_night.b = sf_color_night.b - 5
- end
- end
- elseif sf_entrada ~= sf_entrada_ant then
- sf_entrada_ant = sf_entrada
- if sf_entrada:left() then
- if edit_rgb > 1 then
- edit_rgb = edit_rgb - 1
- end
- elseif sf_entrada:right() then
- if edit_rgb < 3 then
- edit_rgb = edit_rgb + 1
- end
- elseif sf_entrada:cross() then
- return
- end
- end
- sf_entrada_ant = sf_entrada
- screen.waitvblankstart(10)
- end
- end
- function SF_enableAllSatellites()
- local s
- for s = 1,sgp_sat_number do
- sgp_sats[s].no_calcular = 0
- end
- end
- function SF_enableAllStars()
- local s
- for s = 1,sgp_star_number do
- sgp_stars[s].no_calcular = 0
- end
- end
- function SF_sendHTTPheader(sock, filepath)
- sock:send("GET " .. filepath .. " HTTP/1.1\r\n")
- sock:send("Host: celestrak.com\r\n")
- sock:send("User-Agent: Satfinder 1.3\r\n")
- sock:send("Accept: */*;q=0.01\r\n")
- sock:send("Keep-Alive: 300\r\n")
- sock:send("Connection: keep-alive\r\n")
- sock:send("\r\n")
- end
- function SF_downloadTLEs()
- local tle_filename = "visual"
- sf_iss = nil
- screen.clear(sf_sky_color)
- screen.print(30, 0,"> Inicializando conexion WIFI...", sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.clear(sf_sky_color)
- screen.print(30, 0,"> Inicializando conexion WIFI...", sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.waitvblankstart(200)
- -- Inicializar modulo WIFI
- while not ipAddress do
- os.sleep(0.01*100)
- wlan.init()
- wifi, ipAddress = pcall(function() return wlan.getIP() end)
- if wifi == false then
- ipAddress = false
- os.message("No fue posible el acceso a Internet. Por favor, conectese a un punto de acceso.",0)
- wlan.init()
- end
- end
- screen.print(30, 0,"> Inicializando conexion WIFI...", sf_palette[4])
- screen.print(30, 10, "> Obteniendo direccion IP... ".. ipAddress , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(30, 0,"> Inicializando conexion WIFI...", sf_palette[4])
- screen.print(30, 10, "> Obteniendo direccion IP... ".. ipAddress , sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(30, 20, "> Conectando con Celestrak.com..." , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(30, 20, "> Conectando con Celestrak.com..." , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- socket,error = Socket.connect("celestrak.com", 80)
- while not socket:isConnected() do
- os.sleep(0.01*100)
- end
- screen.print(300, 20, "conectado!. ", sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(300, 20, "conectado!. ", sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- SF_sendHTTPheader(socket, "/NORAD/elements/".. tle_filename ..".txt")
- screen.print(30, 30, "> Recibiendo archivo " .. tle_filename .. ".tle", sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(30, 30, "> Recibiendo archivo " .. tle_filename .. ".tle ...", sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- -- Obtenemos el fichero TLE
- local f = io.open ("./tle/"..tle_filename .. ".tle", "w+")
- local buffer_len = 1
- reintentos = 20
- while (buffer_len > 0) do
- screen.waitvblankstart(5)
- local buffer = socket:recv(500)
- if string.len(buffer) > 0 then
- f:write (buffer)
- screen.waitvblankstart(5)
- screen.flip()
- screen.waitvblankstart(5)
- screen.flip()
- buffer_len = string.len(buffer)
- reintentos = 20
- else
- if reintentos > 0 then
- reintentos = reintentos - 1
- screen.waitvblankstart(10)
- screen.flip()
- screen.waitvblankstart(10)
- screen.flip()
- buffer_len = 1
- else
- buffer_len = string.len(buffer)
- end
- end
- end
- f:flush ()
- io.close (f)
- socket:close()
- screen.print(30, 30, "> Recibiendo archivo " .. tle_filename .. ".tle ... OK!", sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(30, 30, "> Recibiendo archivo " .. tle_filename .. ".tle ... OK!", sf_palette[4])
- screen.waitvblankstart(300)
- screen.flip()
- tle_filename = "iridium"
- screen.print(30, 40, "> Conectando con Celestrak.com..." , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(30, 40, "> Conectando con Celestrak.com..." , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- socket,error = Socket.connect("celestrak.com", 80)
- while not socket:isConnected() do
- os.sleep(0.01*100)
- end
- screen.print(300, 40, "conectado!. ", sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(300, 40, "conectado!. ", sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- SF_sendHTTPheader(socket, "/NORAD/elements/".. tle_filename ..".txt")
- screen.print(30, 50, "> Recibiendo archivo " .. tle_filename .. ".tle", sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(30, 50, "> Recibiendo archivo " .. tle_filename .. ".tle ...", sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- -- Obtenemos el fichero TLE
- local f = io.open ("./tle/"..tle_filename .. ".tle", "w+")
- local buffer_len = 1
- reintentos = 20
- while (buffer_len > 0) do
- screen.waitvblankstart(5)
- local buffer = socket:recv(500)
- if string.len(buffer) > 0 then
- f:write (buffer)
- screen.waitvblankstart(5)
- screen.flip()
- screen.waitvblankstart(5)
- screen.flip()
- buffer_len = string.len(buffer)
- reintentos = 20
- else
- if reintentos > 0 then
- reintentos = reintentos - 1
- screen.waitvblankstart(10)
- screen.flip()
- screen.waitvblankstart(10)
- screen.flip()
- buffer_len = 1
- else
- buffer_len = string.len(buffer)
- end
- end
- end
- f:flush ()
- io.close (f)
- socket:close()
- screen.print(30, 50, "> Recibiendo archivo " .. tle_filename .. ".tle ... OK!", sf_palette[4])
- screen.waitvblankstart()
- screen.flip()
- screen.print(30, 50, "> Recibiendo archivo " .. tle_filename .. ".tle ... OK!", sf_palette[4])
- screen.waitvblankstart(100)
- screen.flip()
- screen.print(30, 60, "> Informacion de los satelites actualizada con exito!", sf_palette[4])
- screen.print(30, 70, "> Procesando informacion, espere por favor...", sf_palette[8])
- screen.waitvblankstart()
- screen.flip()
- screen.print(30, 60, "> Informacion de los satelites actualizada con exito!", sf_palette[4])
- screen.print(30, 70, "> Procesando informacion, espere por favor...", sf_palette[8])
- local file = io.open("update.txt", "w+")
- if file ~= nil then
- file:write(tostring(sgp_time.jtime).."\n")
- file:flush(file)
- io.close(file)
- end
- screen.waitvblankstart(300)
- screen.flip()
- wlan.term()
- end
- function SF_drawLineMap( lat1 , lon1 , lat2, lon2, color )
- local px1, py1 = SF_LatLonToXY(lat1, lon1)
- local px2, py2 = SF_LatLonToXY(lat2, lon2)
- draw.line( px1, py1, px2, py2, color)
- end
- function SF_drawBitmapMap( lat , lon , bitmap, xini, yini, xlen, ylen )
- local px, py = SF_LatLonToXY(lat, lon)
- image.blit(px - xlen/2, py - ylen/2, bitmap, xini, yini, xlen, ylen, true)
- end
- function SF_drawSuperPointSky( azimut , elevacion , color )
- if elevacion > sf_sky.elevacion_minima then
- local px, py = SF_AzElevToXY( azimut, elevacion )
- if px > 0 and px < screen.width()-1 and py > 0 and py < screen.height()-1 then
- image.pixel( px , py , color )
- px = px-2
- py = py-4
- screen.print(px, py, "o", color)
- end
- end
- end
- function SF_drawSuperCrossSky( azimut , elevacion , color )
- if elevacion > sf_sky.elevacion_minima then
- local px, py = SF_AzElevToXY( azimut, elevacion )
- if px > 0 and px < screen.width()-1 and py > 0 and py < screen.height()-1 then
- image.pixel( px , py , color )
- px = px-2
- py = py-4
- screen.print(px, py, "x", color)
- end
- end
- end
- function SF_drawSuperPointMap( latitud , longitud , color )
- local px, py = SF_LatLonToXY(latitud, longitud)
- image.pixel( px , py , color )
- px = px-2
- py = py-4
- screen.print(px, py, "o", color)
- end
- function SF_drawSuperCrossMap( latitud , longitud , color )
- local px, py = SF_LatLonToXY(latitud, longitud)
- px = px-2
- py = py-4
- screen.print(px, py, "x", color)
- end
- function SF_drawLabelSatsSky(azimut, elevacion, texto, color)
- if elevacion > sf_sky.elevacion_minima then
- local px, py = SF_AzElevToXY( azimut, elevacion )
- if azimut > 90 and azimut < 270 then
- screen.print(px+ 5, py-10, texto, color)
- else
- screen.print(px+ 5, py+2, texto, color)
- end
- end
- end
- function SF_drawSatellitesSky()
- local s
- for s = 1,sgp_sat_number do
- SF_drawSatSky( s )
- end
- end
- function SF_drawSatellitesMap()
- local s
- for s = 1,sgp_sat_number do
- SF_drawSatMap( s )
- end
- end
- function SF_decimales( valor, precision )
- local absoluto = math.abs (valor)
- return (absoluto - math.floor(absoluto))*10*precision
- end
- function SF_drawBackgroundInfo ()
- --Sol
- draw.fillrect(0,0,236,9,sf_palette[6])
- draw.line(0,0,239,0,sf_palette[1])
- draw.line(0,9,235,9,sf_palette[10])
- draw.fillrect(0,10,236,10,sf_palette[12])
- draw.line(0,19,235,19,sf_palette[14])
- draw.line(0,39,235,39,sf_palette[14])
- draw.fillrect(0,40,236,10,sf_palette[12])
- draw.line(0,49,235,49,sf_palette[14])
- draw.line(0,59,235,59,sf_palette[14])
- draw.fillrect(0,60,236,10,sf_palette[12])
- draw.line(0,69,235,69,sf_palette[14])
- --Luna
- draw.fillrect(0,100,236,10,sf_palette[6])
- draw.line(0,99,235,99,sf_palette[1])
- draw.line(0,109,235,109,sf_palette[10])
- draw.fillrect(0,110,236,10,sf_palette[12])
- draw.line(0,119,235,119,sf_palette[14])
- draw.line(0,139,235,139,sf_palette[14])
- draw.fillrect(0,140,236,10,sf_palette[12])
- draw.line(0,149,235,149,sf_palette[14])
- draw.line(0,159,235,159,sf_palette[14])
- draw.fillrect(0,160,236,10,sf_palette[12])
- draw.line(0,169,235,169,sf_palette[14])
- draw.line(0,189,215,189,sf_palette[14])
- draw.line(215,170,215,189,sf_palette[14])
- draw.fillrect(0,190,190,10,sf_palette[12])
- draw.line(190,190,190,199,sf_palette[14])
- draw.line(0,199,235,199,sf_palette[14])
- draw.fillrect(0,200,236,10,sf_palette[12])
- draw.line(0,209,235,209,sf_palette[14])
- draw.line(0,219,235,219,sf_palette[14])
- draw.fillrect(0,220,236,10,sf_palette[12])
- draw.line(0,229,235,229,sf_palette[14])
- -- Separador intermedio
- draw.fillrect(236,1,3,272,sf_palette[6])
- -- Situación
- draw.fillrect(239,0,241,9,sf_palette[6])
- draw.line(239,0,480,0,sf_palette[1])
- draw.line(239,9,480,9,sf_palette[10])
- draw.line(239,19,480,19,sf_palette[14])
- draw.fillrect(239,10,50,9,sf_palette[12])
- draw.line(289,10,289,19,sf_palette[14])
- draw.line(239,39,480,39,sf_palette[14])
- draw.line(239,29,307,29,sf_palette[14])
- draw.fillrect(239,20,68,9,sf_palette[12])
- draw.line(307,20,307,29,sf_palette[14])
- draw.line(239,49,480,49,sf_palette[14])
- draw.fillrect(239,40,241,9,sf_palette[12])
- -- Hora y fecha
- draw.fillrect(239,80,241,9,sf_palette[6])
- draw.line(239,79,480,79,sf_palette[1])
- draw.line(239,89,480,89,sf_palette[10])
- -- Satelites
- draw.fillrect(239,140,241,9,sf_palette[6])
- draw.line(239,139,480,139,sf_palette[1])
- draw.line(239,149,480,149,sf_palette[10])
- -- Estrellas
- draw.fillrect(239,190,241,9,sf_palette[6])
- draw.line(239,189,480,189,sf_palette[1])
- draw.line(239,199,480,199,sf_palette[10])
- -- PSP
- draw.fillrect(239,230,241,9,sf_palette[6])
- draw.line(239,229,480,229,sf_palette[1])
- draw.line(239,239,480,239,sf_palette[10])
- end
- function SF_drawSunInfo ()
- screen.print(1, 1, " SOL" , sf_palette[14])
- screen.print(1, 11, "Posicion", sf_palette[8])
- screen.print(1, 21, " Azim " .. string.format("%.3d.%.2d",sgp_sun.azi, SF_decimales( sgp_sun.azi,2)), sf_palette[4])
- screen.print(1, 31, " Elev " .. string.format ("%+.2d.%.2d",sgp_sun.ele, SF_decimales( sgp_sun.ele,2)), sf_palette[4])
- if sgp_sun.lat >= 0 then
- screen.print(113, 21, "Lat " .. string.format ("%.2d.%.2d",sgp_sun.lat,SF_decimales(sgp_sun.lat,2)) .. " N" , sf_palette[4])
- else
- screen.print(113, 21, "Lat " .. string.format ("%.2d.%.2d",-sgp_sun.lat,SF_decimales(sgp_sun.lat,2)) .. " S" , sf_palette[4])
- end
- if sgp_sun.lon >= 0 then
- screen.print(113, 31, "Lon " .. string.format ("%.3d.%.2d",sgp_sun.lon,SF_decimales(sgp_sun.lon,2)) .. " E", sf_palette[4])
- else
- screen.print(113, 31, "Lon " .. string.format ("%.3d.%.2d",-sgp_sun.lon,SF_decimales(sgp_sun.lon,2)) .. " W", sf_palette[4])
- end
- screen.print(1, 41, "Distancia en millones de KMs", sf_palette[8])
- screen.print(1, 51, " 142.7 < ", sf_palette[8])
- screen.print(73, 51, string.format ("%.6f",sgp_sun.alt/1000000) , sf_palette[4])
- screen.print(153, 51, " < 151.8", sf_palette[8])
- screen.print(1, 61, "Salidas y puestas de Sol" , sf_palette[8])
- if sgp_sun.ele > 0 then
- screen.print(1, 71, " Ha salido a las " .. sgp_sun.raise.hour .. ":" .. string.format ("%.2d",sgp_sun.raise.min) , sf_palette[4])
- screen.print(1, 81, " Se va poner a las " .. sgp_sun.set.hour .. ":" .. string.format ("%.2d",sgp_sun.set.min) , sf_palette[4])
- else
- screen.print(1, 71, " Se ha puesto a las " .. sgp_sun.set.hour .. ":" .. string.format ("%.2d",sgp_sun.set.min) , sf_palette[4])
- screen.print(1, 81, " Va a salir a las " .. sgp_sun.raise.hour .. ":" .. string.format ("%.2d",sgp_sun.raise.min) , sf_palette[4])
- end
- end
- function SF_drawMoonInfo()
- screen.print(1, 101, " LUNA" , sf_palette[14])
- screen.print(1, 111, "Posicion", sf_palette[8])
- screen.print(1, 121, " Azim " .. string.format("%.3d.%.2d",sgp_moon.azi, SF_decimales( sgp_moon.azi,2)), sf_palette[4])
- screen.print(1, 131, " Elev " .. string.format ("%+.2d.%.2d",sgp_moon.ele, SF_decimales( sgp_moon.ele,2)), sf_palette[4])
- if sgp_moon.lat >= 0 then
- screen.print(113, 121, "Lat " .. string.format ("%.2d.%.2d",sgp_moon.lat,SF_decimales(sgp_moon.lat,2)) .. " N" , sf_palette[4])
- else
- screen.print(113, 121, "Lat " .. string.format ("%.2d.%.2d",-sgp_moon.lat,SF_decimales(sgp_moon.lat,2)) .. " S" , sf_palette[4])
- end
- if sgp_moon.lon >= 0 then
- screen.print(113, 131, "Lon " .. string.format ("%.3d.%.2d",sgp_moon.lon,SF_decimales(sgp_moon.lon,2)) .. " E", sf_palette[4])
- else
- screen.print(113, 131, "Lon " .. string.format ("%.3d.%.2d",-sgp_moon.lon,SF_decimales(sgp_moon.lon,2)) .. " W", sf_palette[4])
- end
- screen.print(1, 141, "Distancia en miles de KMs", sf_palette[8])
- screen.print(1, 151, " 363.0 < ", sf_palette[8])
- screen.print(73, 151, string.format ("%.6f",sgp_moon.dist/1000) , sf_palette[4])
- screen.print(153, 151, " < 405.0", sf_palette[8])
- screen.print(1, 161, "Salidas y puestas de Luna" , sf_palette[8])
- if sgp_moon.ele > 0 then
- screen.print(1, 171, " Ha salido a las " .. sgp_moon.raise.hour.. ":" .. string.format ("%.2d",sgp_moon.raise.min) , sf_palette[4])
- screen.print(1, 181," Se va poner a las " .. sgp_moon.set.hour.. ":" .. string.format ("%.2d",sgp_moon.set.min) , sf_palette[4])
- else
- screen.print(1, 171, " Se ha puesto a las " .. sgp_moon.set.hour.. ":" .. string.format ("%.2d",sgp_moon.set.min) , sf_palette[4])
- screen.print(1, 181," Va a salir a las " .. sgp_moon.raise.hour.. ":" .. string.format ("%.2d",sgp_moon.raise.min) , sf_palette[4])
- end
- screen.print(1, 191, "Iluminacion disco lunar", sf_palette[8])
- screen.print(185, 191, " " .. string.format ("%d", sgp_moon.phase * 100) .. "%" , sf_palette[4])
- screen.print(1, 201, "Progreso del ciclo lunar", sf_palette[8])
- screen.print(1, 211, " " .. sgp_moon.age.d .. "dias " .. sgp_moon.age.h .. "horas " .. sgp_moon.age.m .. "min (" .. string.format ("%d", sgp_moon.age.cicle * 100) .. "%)" , sf_palette[4])
- screen.print(1, 221, "Proximas fases lunares", sf_palette[8])
- local ye, mo, da, ho, mi, se = SGP_Julian_To_Date(sgp_moon.first_quarter_moon)
- screen.print(1, 231, " Creciente " .. string.format ("%.2d",da) .. "/" .. string.format ("%.2d",mo) .."/" .. ye .. " " .. string.format ("%.2d",ho) .. ":" .. string.format ("%.2d",mi), sf_palette[4])
- ye, mo, da, ho, mi, se = SGP_Julian_To_Date(sgp_moon.full_moon)
- screen.print(1, 241, " Llena " .. string.format ("%.2d",da) .. "/" .. string.format ("%.2d",mo) .."/" .. ye .. " " .. string.format ("%.2d",ho) .. ":" .. string.format ("%.2d",mi), sf_palette[4])
- ye, mo, da, ho, mi, se = SGP_Julian_To_Date(sgp_moon.third_quarter_moon)
- screen.print(1, 251, " Menguante " .. string.format ("%.2d",da) .. "/" .. string.format ("%.2d",mo) .."/" .. ye .. " " .. string.format ("%.2d",ho) .. ":" .. string.format ("%.2d",mi), sf_palette[4])
- ye, mo, da, ho, mi, se = SGP_Julian_To_Date(sgp_moon.new_moon)
- screen.print(1, 261, " Nueva " .. string.format ("%.2d",da) .. "/" .. string.format ("%.2d",mo) .."/" .. ye .. " " .. string.format ("%.2d",ho) .. ":" .. string.format ("%.2d",mi), sf_palette[4])
- end
- function SF_drawStarsInfo()
- screen.print(240, 191, " ESTRELLAS" , sf_palette[14])
- screen.print(240, 201, "Estrellas cargadas: " , sf_palette[8])
- screen.print(400, 201, sgp_star_number , sf_palette[4])
- screen.print(240, 211, "Magnitud limite actual: " , sf_palette[8])
- screen.print(432, 211, string.format ("%.2f",sgp_mag_limit), sf_palette[4])
- end
- function SF_drawSatsInfo()
- screen.print(240, 141, " SATELITES" , sf_palette[14])
- screen.print(240, 151, "Satelites cargados: " , sf_palette[8])
- screen.print(400, 151, sgp_sat_number , sf_palette[4])
- if sf_iss ~= nil then
- screen.print(240, 161, "ISS Azimut: ", sf_palette[8])
- screen.print(360, 161, string.format ("%.2f",sgp_sats[sf_iss].azimut) , sf_palette[4])
- screen.print(240, 171, "ISS Elevacion: ", sf_palette[8])
- screen.print(360, 171, string.format ("%.2f",sgp_sats[sf_iss].elevacion) , sf_palette[4])
- end
- end
- function SF_drawTimeInfo()
- screen.print(240, 81, " FECHA Y HORA" , sf_palette[14])
- screen.print(240, 91, "Local: ",sf_palette[8])
- screen.print(304, 91, sgp_time.day ..
- "/" .. sgp_time.month ..
- "/" .. sgp_time.year,sf_palette[4])
- screen.print(400, 91, sgp_time.hour ..
- ":" .. string.format("%.2d",sgp_time.min) ..
- ":" .. string.format("%.2d",sgp_time.sec), sf_palette[4])
- screen.print(240, 101, "UTC: ",sf_palette[8])
- screen.print(304, 101, sgp_time.uday ..
- "/" .. sgp_time.umonth ..
- "/" .. sgp_time.uyear,sf_palette[4])
- screen.print(400, 101, sgp_time.uhour ..
- ":" .. string.format("%.2d",sgp_time.umin) ..
- ":" .. string.format("%.2d",sgp_time.usec), sf_palette[4])
- screen.print(240, 111, "Zona horaria:" , sf_palette[8])
- screen.print(344, 111, "GMT" .. string.format ("%+03d",sgp_location.UTC_offset), sf_palette[4])
- screen.print(416, 111, "DST:" , sf_palette[8])
- if sgp_location.dst then
- screen.print(448, 111, "SI", sf_palette[4])
- else
- screen.print(448, 111, "NO", sf_palette[4])
- end
- end
- function SF_drawInfoBar(completa)
- if completa then
- -- Fondo de la barra (borra lo anterior)
- draw.fillrect(0, 0, 480, 9, sf_palette[14])
- draw.line(0,9, 479,9,sf_palette[10])
- -- Bateria
- local level = batt.percent()
- if level < 0 or level > 100 then
- level = "--"
- end
- screen.print(1, 1, "Bat:"..level .. "%" , sf_palette[8])
- -- Magnitud umbral
- screen.print(80, 1, "Mag:"..string.format ("%.1f",sgp_mag_limit), sf_palette[8])
- -- Fremes per second
- screen.print(160, 1, "Fps:"..string.format ("%.1f",sf_fps), sf_palette[8])
- -- Zoom
- screen.print(240, 1, "Zoom:"..string.format ("%.1fx",sf_sky.radio/241), sf_palette[8])
- -- Rotación
- screen.print(336, 1, "Rot:"..string.format ("%.1f",sf_sky.rotacion), sf_palette[8])
- else
- draw.fillrect(414, 0, 479, 9, sf_palette[14])
- draw.line(414,9, 479,9,sf_palette[10])
- draw.line(414,9, 414,0,sf_palette[10])
- end
- -- Hora actual
- SGP_getCurrentTime()
- if sgp_time.hour >= 10 then
- screen.print(416, 1, sgp_time.hour ..
- ":" .. string.format("%.2d",sgp_time.min) ..
- ":" .. string.format("%.2d",sgp_time.sec) , sf_palette[10])
- else
- screen.print(424, 1,sgp_time.hour ..
- ":" .. string.format("%.2d",sgp_time.min) ..
- ":" .. string.format("%.2d",sgp_time.sec), sf_palette[10])
- end
- end
- function SF_drawLocationInfo ()
- screen.print(240, 1, " SITUACION OBSERVADOR" , sf_palette[14])
- screen.print(240, 11, "Nombre" , sf_palette[8])
- screen.print(304, 11, sgp_location.name, sf_palette[4])
- screen.print(240, 21, "Posicion", sf_palette[8])
- if sgp_location.lat >= 0 then
- screen.print(368, 21, "Lat " .. string.format ("%.2d.%.2d",sgp_location.lat,SF_decimales(sgp_location.lat,2)) .. " N" , sf_palette[4])
- else
- screen.print(368, 21, "Lat " .. string.format ("%.2d.%.2d",-sgp_location.lat,SF_decimales(sgp_location.lat,2)) .. " S" , sf_palette[4])
- end
- if sgp_location.lon >= 0 then
- screen.print(368, 31, "Lon " .. string.format ("%.3d.%.2d",sgp_location.lon,SF_decimales(sgp_location.lon,2)) .. " E", sf_palette[4])
- else
- screen.print(368, 31, "Lon " .. string.format ("%.3d.%.2d",-sgp_location.lon,SF_decimales(sgp_location.lon,2)) .. " W", sf_palette[4])
- end
- screen.print(248, 31, "Alt " .. string.format("%.4d m",sgp_location.alt), sf_palette[4])
- screen.print(240, 41, "La Noche" , sf_palette[8])
- if sgp_sun.ele > const_twilightCivil then
- screen.print(240, 51, " Ha terminado a las " .. sgp_location.day.hour.. ":" .. string.format ("%.2d",sgp_location.day.min) , sf_palette[4])
- screen.print(240, 61, " Va a empezar a las " .. sgp_location.night.hour.. ":" .. string.format ("%.2d",sgp_location.night.min) , sf_palette[4])
- else
- screen.print(240, 51, " Ha empezado a las " .. sgp_location.night.hour.. ":" .. string.format ("%.2d",sgp_location.night.min) , sf_palette[4])
- screen.print(240, 61, " Va a terminar a las " .. sgp_location.day.hour.. ":" .. string.format ("%.2d",sgp_location.day.min) , sf_palette[4])
- end
- end
- function SF_drawPSPInfo()
- screen.print(240, 231, " PSP" , sf_palette[14])
- SF_drawMemLevel(240, 241, sf_palette[4])
- SF_drawBatLevel(240, 251, sf_palette[4])
- SF_drawTempLevel(240, 261, sf_palette[4])
- end
- function SF_drawAllNextVisiblePassList()
- local continua_buscando = true
- local i
- if sf_next_limit == 0 then
- i = 1
- while i <= sgp_sat_number and (sf_next_limit < sf_next_max) and continua_buscando do
- screen.clear(sf_sky_color)
- draw.fillrect(0, 0, 480, 10, sf_palette[14])
- SF_drawInfoBar(false)
- screen.print( 0, 1, " Proximos avistamientos en 30 minutos (".. string.format("%d",i/sgp_sat_number * 100) .. "%)", sf_palette[1])
- draw.line(0,9, 479,9,sf_palette[10])
- draw.fillrect(0, 10, 480, 19, sf_palette[14])
- screen.print( 0, 11, " FECHA |INICIO |MAXIMO |FIN |NOMBRE ", sf_palette[8])
- screen.print( 0, 21, " DD/MM/AAAA|HH:MM EL AZ|HH:MM EL AZ|HH:MM EL AZ| ", sf_palette[8])
- draw.line(0,29, 479,29,sf_palette[10])
- local j
- local limite
- if sf_next_limit > 23 then
- limite = 23
- else
- limite = sf_next_limit
- end
- for j = 1,limite do
- local c = math.floor ((90- sf_next_passes[j].max_elevacion)/90*12)
- screen.print( 8, 21 + 10*j, sf_next_passes[j].linea , sf_palette[4 + c])
- end
- draw.line(0,259, 479,259,sf_palette[10])
- draw.fillrect(0, 260, 480, 272, sf_palette[14])
- screen.print(0, 261, " Pulsa CUADRADO para parar." , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.clear(sf_sky_color)
- draw.fillrect(0, 0, 480, 10, sf_palette[14])
- SF_drawInfoBar(false)
- screen.print( 0, 1, " Proximos avistamientos en 30 minutos (".. string.format("%d",i/sgp_sat_number * 100) .. "%)", sf_palette[1])
- draw.line(0,9, 479,9,sf_palette[10])
- draw.fillrect(0, 10, 480, 20, sf_palette[14])
- screen.print( 0, 11, " FECHA |INICIO |MAXIMO |FIN |NOMBRE ", sf_palette[8])
- screen.print( 0, 21, " DD/MM/AAAA|HH:MM EL AZ|HH:MM EL AZ|HH:MM EL AZ| ", sf_palette[8])
- draw.line(0,29, 479,29,sf_palette[10])
- for j = 1,limite do
- local c = math.floor ((90- sf_next_passes[j].max_elevacion)/90*12)
- screen.print( 8, 21 + 10*j, sf_next_passes[j].linea , sf_palette[4 + c])
- end
- draw.line(0,259, 479,259,sf_palette[10])
- draw.fillrect(0, 260, 480, 272, sf_palette[14])
- screen.print(0, 261, " Pulsa CUADRADO para parar." , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- continua_buscando = SGP_calculateAllNextVisiblePass(i)
- i = i + 1
- end
- if sf_next_current > 23 then
- sf_next_current = 23
- end
- end
- while true do
- screen.clear(sf_sky_color)
- draw.fillrect(0, 0, 480, 10, sf_palette[14])
- SF_drawInfoBar(false)
- screen.print( 0, 1, " Proximos avistamientos en 30 minutos", sf_palette[1])
- draw.line(0,9, 479,9,sf_palette[10])
- draw.fillrect(0, 10, 480, 20, sf_palette[14])
- screen.print( 0, 11, " FECHA |INICIO |MAXIMO |FIN |NOMBRE ", sf_palette[8])
- screen.print( 0, 21, " DD/MM/AAAA|HH:MM EL AZ|HH:MM EL AZ|HH:MM EL AZ| ", sf_palette[8])
- draw.line(0,29, 479,29,sf_palette[10])
- local i
- local limite
- if sf_next_limit > 23 then
- limite = 23
- else
- limite = sf_next_limit
- end
- if limite == 0 then
- screen.print( 8, 21 + 10*1, "Ningun satelite va a ser visible en 30 minutos." , sf_palette[8])
- screen.print( 8, 21 + 10*2, "Intentelo otra vez mas tarde." , sf_palette[8])
- else
- for i = 1,limite do
- if sf_next_current == i then
- screen.print( 0, 21 + 10*i, ">"..sf_next_passes[i].linea , sf_palette[1])
- else
- local c = math.floor ((90- sf_next_passes[i].max_elevacion)/90*12)
- screen.print( 8, 21 + 10*i, sf_next_passes[i].linea , sf_palette[4 + c])
- end
- end
- end
- draw.line(0,259, 479,259,sf_palette[10])
- draw.fillrect(0, 260, 480, 272, sf_palette[14])
- screen.print(0, 261, " Pulsa X para seleccionar. Pulsa O para buscar otra vez." , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- sf_entrada = Controls.read()
- if sf_entrada:down() then
- if sf_next_current < limite then
- sf_next_current = sf_next_current + 1
- end
- elseif sf_entrada:up() then
- if sf_next_current > 1 then
- sf_next_current = sf_next_current - 1
- end
- elseif sf_entrada ~= sf_entrada_ant then
- sf_entrada_ant = sf_entrada
- if sf_entrada:cross() then
- if sf_next_current > 0 then
- sf_selected_sat = sf_next_passes[sf_next_current].sat
- SF_generateNextPassPathSky(sf_selected_sat)
- end
- return
- end
- if sf_entrada:circle() then
- sf_next_limit = 0
- sf_next_current = 0
- SF_drawAllNextVisiblePassList()
- return
- end
- if sf_entrada:r() and sf_entrada:l() then
- SF_screenshot()
- end
- end
- sf_entrada_ant = sf_entrada
- screen.waitvblankstart(5)
- end
- end
- function SF_drawSatNextVisiblePassList(sat)
- local continua_buscando = true
- screen.clear(sf_sky_color)
- draw.fillrect(0, 0, 480, 10, sf_palette[14])
- SF_drawInfoBar(false)
- screen.waitvblankstart()
- screen.flip()
- screen.clear(sf_sky_color)
- draw.fillrect(0, 0, 480, 10, sf_palette[14])
- SF_drawInfoBar(false)
- screen.waitvblankstart()
- screen.flip()
- SF_drawInfoBar(false)
- screen.print( 0, 1, " Proximos avistamientos del satelite "..sgp_sats[sat].nombre, sf_palette[1])
- draw.line(0,9, 479,9,sf_palette[10])
- draw.fillrect(0, 10, 480, 19, sf_palette[14])
- screen.print( 0, 11, " FECHA | INICIO | MAXIMO | FIN ", sf_palette[1])
- screen.print( 0, 21, " DD/MM/AAAA| HH:MM EL AZ| HH:MM EL AZ| HH:MM EL AZ ", sf_palette[1])
- draw.line(0,29, 479,29,sf_palette[10])
- local i
- for i = 1,sf_pass_limit do
- if sf_pass_current == i then
- screen.print( 8, 21 + 10*i, sf_passes[i].linea , sf_palette[4])
- else
- local c = math.floor ((90- sf_passes[i].max_elevacion)/90*12)
- screen.print( 8, 21 + 10*i, sf_passes[i].linea , sf_palette[4 + c])
- end
- end
- draw.line(0,259, 479,259,sf_palette[10])
- draw.fillrect(0, 260, 480, 272, sf_palette[14])
- screen.waitvblankstart()
- screen.flip()
- SF_drawInfoBar(false)
- screen.print( 0, 1, " Proximos avistamientos del satelite "..sgp_sats[sat].nombre, sf_palette[1])
- draw.line(0,9, 479,9,sf_palette[10])
- draw.fillrect(0, 10, 480, 19, sf_palette[14])
- screen.print( 0, 11, " FECHA | INICIO | MAXIMO | FIN ", sf_palette[1])
- screen.print( 0, 21, " DD/MM/AAAA| HH:MM EL AZ| HH:MM EL AZ| HH:MM EL AZ ", sf_palette[1])
- draw.line(0,29, 479,29,sf_palette[10])
- for i = 1,sf_pass_limit do
- if sf_pass_current == i then
- screen.print( 8, 21 + 10*i, sf_passes[i].linea , sf_palette[4])
- else
- local c = math.floor ((90- sf_passes[i].max_elevacion)/90*12)
- screen.print( 8, 21 + 10*i, sf_passes[i].linea , sf_palette[4 + c])
- end
- end
- draw.line(0,259, 479,259,sf_palette[10])
- draw.fillrect(0, 260, 480, 272, sf_palette[14])
- screen.waitvblankstart()
- screen.flip()
- screen.print(0, 261, " Pulsa CUADRADO para parar." , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- screen.print(0, 261, " Pulsa CUADRADO para parar." , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- while (sf_pass_limit < sf_pass_max) and continua_buscando do
- continua_buscando = SGP_calculateSatNextVisiblePass(sat)
- end
- while true do
- screen.clear(sf_sky_color)
- draw.fillrect(0, 0, 480, 10, sf_palette[14])
- SF_drawInfoBar(false)
- screen.print( 0, 1, " Proximos avistamientos del satelite "..sgp_sats[sat].nombre, sf_palette[1])
- draw.line(0,9, 479,9,sf_palette[10])
- draw.fillrect(0, 10, 480, 19, sf_palette[14])
- screen.print( 0, 11, " FECHA | INICIO | MAXIMO | FIN ", sf_palette[1])
- screen.print( 0, 21, " DD/MM/AAAA| HH:MM EL AZ| HH:MM EL AZ| HH:MM EL AZ ", sf_palette[1])
- draw.line(0,29, 479,29,sf_palette[10])
- local i
- for i = 1,sf_pass_limit do
- if sf_pass_current == i then
- screen.print( 0, 21 + 10*i, ">" .. sf_passes[i].linea , sf_palette[1])
- else
- local c = math.floor ((90- sf_passes[i].max_elevacion)/90*12)
- screen.print( 8, 21 + 10*i, sf_passes[i].linea , sf_palette[4 + c])
- end
- end
- draw.line(0,259, 479,259,sf_palette[10])
- draw.fillrect(0, 260, 480, 272, sf_palette[14])
- screen.print(0, 261, " Pulsa X para seleccionar la que quiera ver marcada." , sf_palette[1])
- screen.waitvblankstart()
- screen.flip()
- sf_entrada = Controls.read()
- if sf_entrada:down() then
- if sf_pass_current < sf_pass_limit then
- sf_pass_current = sf_pass_current + 1
- end
- elseif sf_entrada:up() then
- if sf_pass_current > 1 then
- sf_pass_current = sf_pass_current - 1
- end
- elseif sf_entrada ~= sf_entrada_ant then
- sf_entrada_ant = sf_entrada
- if sf_entrada:cross() then
- sf_selected_sat = sat
- SF_generatePassPathSky(sat)
- return
- end
- if sf_entrada:r() and sf_entrada:l() then
- SF_screenshot()
- end
- end
- sf_entrada_ant = sf_entrada
- screen.waitvblankstart(10)
- end
- end
- function SGP_calculateAllNextVisiblePass(s)
- local jtime
- SGP_getCurrentTime()
- jtime = sgp_time.ujtime
- sf_next_limit = sf_next_limit + 1
- sf_next_current = sf_next_limit
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (s , jtime)
- -- buscamos la proxima vez que estará visible y por encima del horizonte en un plazo de 1 hora
- -- incrementamos mucho cuando su elevacion baja y poco cuando sube
- local sf_mostrar_progreso = 0
- local one_hour_after = jtime + const_julian_minute * 30
- while not ( sgp_sats[s].elevacion > sf_sky.elevacion_minima and sgp_sats[s].visible) do
- if sgp_sats[s].elevacion > sgp_sats[s].elevacion_ant and sgp_sun.ele < 15 then
- jtime = jtime + const_julian_minute * sf_next_visible_precision
- else
- jtime = jtime + const_julian_minute * sf_next_visible_precision * 50
- end
- if jtime >= one_hour_after then
- --lo dejamos todo como estaba (en el tiempo real), incluso la dirección, llamando dos veces
- SGP_calculateSun (sgp_time.ujtime - const_julian_minute)
- SGP_calculateSatellite (s , sgp_time.ujtime - const_julian_minute)
- SGP_calculateSun (sgp_time.ujtime)
- SGP_calculateSatellite (s , sgp_time.ujtime)
- SF_erase(1, 21+sf_next_limit*10, 60)
- sf_next_limit = sf_next_limit - 1
- sf_next_current = sf_next_limit
- screen.waitvblankstart()
- screen.flip()
- return true
- end
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (s , jtime)
- if sf_mostrar_progreso <= 0 then
- sf_mostrar_progreso = 15
- local jt_temp = SGP_UTC_to_Local(jtime)
- local year , month, day, hour, minute, second = SGP_Julian_To_Date(jt_temp)
- SF_drawInfoBar(false)
- if sf_next_current <= 22 then
- SF_erase(8, 21+sf_next_limit*10, 60)
- screen.print(8, 21+sf_next_limit*10, string.format ("%02d",day) .. "/" .. string.format ("%02d",month)
- .. "/" .. year .. " " .. string.format ("%02d",hour) .. ":" .. string.format("%02d",minute)..
- " " .. sgp_sats[s].nombre, sf_palette[12])
- screen.waitvblankstart()
- screen.flip()
- end
- sf_entrada = Controls.read()
- if sf_entrada ~= sf_entrada_ant then
- sf_entrada_ant = sf_entrada
- if sf_entrada:square() then
- --lo dejamos todo como estaba (en el tiempo real), incluso la dirección, llamando dos veces
- SGP_calculateSun (sgp_time.ujtime - const_julian_minute)
- SGP_calculateSatellite (s , sgp_time.ujtime - const_julian_minute)
- SGP_calculateSun (sgp_time.ujtime)
- SGP_calculateSatellite (s , sgp_time.ujtime)
- SF_erase(1, 21+sf_next_limit*10, 60)
- sf_next_limit = sf_next_limit - 1
- sf_next_current = sf_next_limit
- screen.waitvblankstart()
- screen.flip()
- return false
- end
- end
- sf_entrada_ant = sf_entrada
- else
- sf_mostrar_progreso = sf_mostrar_progreso - 1
- end
- end
- -- una vez encontrado un punto donde el satelite es visible por encima de la elevación minima establecida
- -- buscamos el inicio de este hecho retrocediendo en saltitos pequeños
- repeat
- jtime = jtime - const_julian_minute * sf_next_visible_precision * 0.2
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (s , jtime)
- until ( not sgp_sats[s].visible or sgp_sats[s].elevacion <= sf_sky.elevacion_minima)
- --hemos encontrado cuando empieza a ser visible. Lo apuntamos.
- jtime = jtime + const_julian_minute * sf_next_visible_precision * 0.2
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (s , jtime)
- sgp_sats[s].no_calcular = 0
- local temp_jt = SGP_UTC_to_Local(jtime)
- local temp_ele = sgp_sats[s].elevacion
- local temp_azi = sgp_sats[s].azimut
- --Ahora vamos a ver la elevación maxima visible que va a tener avanzando en saltos pequeños
- repeat
- jtime = jtime + const_julian_minute * sf_next_visible_precision * 0.2
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (s , jtime)
- until ( (sgp_sats[s].elevacion < sgp_sats[s].elevacion_ant) or (not sgp_sats[s].visible) or (sgp_sats[s].elevacion < sf_sky.elevacion_minima))
- jtime = jtime - const_julian_minute * sf_next_visible_precision * 0.2
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (s , jtime)
- local j = 1
- local momento = SGP_UTC_to_Local(jtime)
- while j < sf_next_limit and sf_next_passes[j].max_jt < momento do
- j = j + 1
- end
- if (j < sf_next_limit) then
- local k = sf_next_limit-1
- while k >= j do
- sf_next_passes[k+1].ini_jt = sf_next_passes[k].ini_jt
- sf_next_passes[k+1].max_jt = sf_next_passes[k].max_jt
- sf_next_passes[k+1].fin_jt = sf_next_passes[k].fin_jt
- sf_next_passes[k+1].ini_azimut = sf_next_passes[k].ini_azimut
- sf_next_passes[k+1].max_azimut = sf_next_passes[k].max_azimut
- sf_next_passes[k+1].fin_azimut = sf_next_passes[k].fin_azimut
- sf_next_passes[k+1].ini_elevacion = sf_next_passes[k].ini_elevacion
- sf_next_passes[k+1].max_elevacion = sf_next_passes[k].max_elevacion
- sf_next_passes[k+1].fin_elevacion = sf_next_passes[k].fin_elevacion
- sf_next_passes[k+1].linea = sf_next_passes[k].linea
- sf_next_passes[k+1].sat = sf_next_passes[k].sat
- k = k - 1
- end
- sf_next_current = j
- end
- sf_next_passes[sf_next_current].ini_jt = temp_jt
- sf_next_passes[sf_next_current].ini_elevacion = temp_ele
- sf_next_passes[sf_next_current].ini_azimut = temp_azi
- --apuntamos la elevacion maxima visible y ya que estamos el azimut
- sf_next_passes[sf_next_current].max_jt = SGP_UTC_to_Local(jtime)
- sf_next_passes[sf_next_current].max_elevacion = sgp_sats[s].elevacion
- sf_next_passes[sf_next_current].max_azimut = sgp_sats[s].azimut
- --Ahora vamos a ver donde termina de ser visible
- repeat
- jtime = jtime + const_julian_minute * sf_next_visible_precision * 0.2
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (s , jtime)
- until ( (not sgp_sats[s].visible) or (sgp_sats[s].elevacion < sf_sky.elevacion_minima))
- jtime = jtime - const_julian_minute * sf_next_visible_precision * 0.2
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (s , jtime)
- --apuntamos donde termina de verse
- sf_next_passes[sf_next_current].fin_jt = SGP_UTC_to_Local(jtime)
- sf_next_passes[sf_next_current].fin_elevacion = sgp_sats[s].elevacion
- sf_next_passes[sf_next_current].fin_azimut = sgp_sats[s].azimut
- sf_next_passes[sf_next_current].sat = s
- --lo dejamos todo como estaba (en el tiempo real), incluso la dirección, llamando dos veces
- SGP_calculateSun (sgp_time.ujtime - const_julian_minute)
- SGP_calculateSatellite (s , sgp_time.ujtime - const_julian_minute)
- SGP_calculateSun (sgp_time.ujtime)
- SGP_calculateSatellite (s , sgp_time.ujtime)
- local year, month, day, hour, minute, second = SGP_Julian_To_Date(sf_next_passes[sf_next_current].ini_jt)
- sf_next_passes[sf_next_current].linea = string.format ("%02d",day) .. "/" .. string.format ("%02d",month)
- .. "/" .. year .. " " .. string.format ("%02d",hour) .. ":" .. string.format("%02d",minute)
- .. " " .. string.format("%02d", sf_next_passes[sf_next_current].ini_elevacion) .. " "
- .. SF_azimutToString(sf_next_passes[sf_next_current].ini_azimut) .. " "
- year, month, day, hour, minute, second = SGP_Julian_To_Date(sf_next_passes[sf_next_current].max_jt)
- sf_next_passes[sf_next_current].linea = sf_next_passes[sf_next_current].linea
- .. string.format ("%02d",hour) .. ":" .. string.format("%02d",minute)
- .. " " .. string.format("%02d", sf_next_passes[sf_next_current].max_elevacion) .. " "
- .. SF_azimutToString(sf_next_passes[sf_next_current].max_azimut) .. " "
- year, month, day, hour, minute, second = SGP_Julian_To_Date(sf_next_passes[sf_next_current].fin_jt)
- sf_next_passes[sf_next_current].linea = sf_next_passes[sf_next_current].linea
- .. string.format ("%02d",hour) .. ":" .. string.format("%02d",minute)
- .. " " .. string.format("%02d", sf_next_passes[sf_next_current].fin_elevacion) .. " "
- .. SF_azimutToString(sf_next_passes[sf_next_current].fin_azimut) .. " " .. sgp_sats[s].nombre
- return true
- end
- function SGP_calculateSatNextVisiblePass(s)
- local entrada
- local jtime
- if sf_pass_limit == 0 then
- SGP_getCurrentTime()
- jtime = sgp_time.ujtime
- else
- jtime = sf_passes[sf_pass_limit].fin_jt + const_julian_minute * 20
- end
- sf_pass_limit = sf_pass_limit + 1
- sf_pass_current = sf_pass_limit
- -- no sabemos donde se encuentra ahora mismo el satélite, pero no queremos
- -- que se encuentre a la vista, asi que si es así, lo metemos en el horizonte
- -- con saltos grandes de 15 minutos
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (s , jtime)
- -- buscamos la proxima vez que estará visible y por encima del horizonte.
- -- incrementamos mucho cuando su elevacion baja y poco cuando sube
- local sf_mostrar_progreso = 0
- while not ( sgp_sats[s].elevacion > sf_sky.elevacion_minima and sgp_sats[s].visible ) do
- if sgp_sats[s].elevacion > sgp_sats[s].elevacion_ant and sgp_sun.ele < 15 then
- jtime = jtime + const_julian_minute * sf_next_visible_precision
- else
- jtime = jtime + const_julian_minute * sf_next_visible_precision * 50
- end
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (s , jtime)
- if sf_mostrar_progreso <= 0 then
- sf_mostrar_progreso = 15
- local jt_temp = SGP_UTC_to_Local(jtime)
- local year , month, day, hour, minute, second = SGP_Julian_To_Date(jt_temp)
- SF_drawInfoBar(false)
- SF_erase(8, 21+sf_pass_limit*10, 60)
- screen.print(8, 21+sf_pass_limit*10, string.format ("%02d",day) .. "/" .. string.format ("%02d",month)
- .. "/" .. year .. " " .. string.format ("%02d",hour) .. ":" .. string.format("%02d",minute), sf_palette[12])
- screen.waitvblankstart()
- screen.flip()
- entrada = Controls.read()
- if entrada:square() then
- --lo dejamos todo como estaba (en el tiempo real), incluso la dirección, llamando dos veces
- SGP_calculateSun (sgp_time.ujtime - const_julian_minute)
- SGP_calculateSatellite (s , sgp_time.ujtime - const_julian_minute)
- SGP_calculateSun (sgp_time.ujtime)
- SGP_calculateSatellite (s , sgp_time.ujtime)
- sf_pass_limit = sf_pass_limit - 1
- sf_pass_current = sf_pass_limit
- SF_erase(1, 20+sf_pass_limit*10, 60)
- screen.waitvblankstart()
- screen.flip()
- return false
- end
- else
- sf_mostrar_progreso = sf_mostrar_progreso - 1
- end
- end
- -- una vez encontrado un punto donde el satelite es visible por encima de la elevación minima establecida
- -- buscamos el inicio de este hecho retrocediendo en saltitos pequeños
- repeat
- jtime = jtime - const_julian_minute * sf_next_visible_precision * 0.2
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (s , jtime)
- until ( not sgp_sats[s].visible or sgp_sats[s].elevacion <= sf_sky.elevacion_minima)
- --hemos encontrado cuando empieza a ser visible. Lo apuntamos.
- jtime = jtime + const_julian_minute * sf_next_visible_precision * 0.2
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (s , jtime)
- sf_passes[sf_pass_current].ini_jt = SGP_UTC_to_Local(jtime)
- sf_passes[sf_pass_current].ini_elevacion = sgp_sats[s].elevacion
- sf_passes[sf_pass_current].ini_azimut = sgp_sats[s].azimut
- --Ahora vamos a ver la elevación maxima visible que va a tener avanzando en saltos pequeños
- repeat
- jtime = jtime + const_julian_minute * sf_next_visible_precision * 0.2
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (s , jtime)
- until ( (sgp_sats[s].elevacion < sgp_sats[s].elevacion_ant) or (not sgp_sats[s].visible) or (sgp_sats[s].elevacion < sf_sky.elevacion_minima))
- jtime = jtime - const_julian_minute * sf_next_visible_precision * 0.2
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (s , jtime)
- --apuntamos la elevacion maxima visible y ya que estamos el azimut
- sf_passes[sf_pass_current].max_jt = SGP_UTC_to_Local(jtime)
- sf_passes[sf_pass_current].max_elevacion = sgp_sats[s].elevacion
- sf_passes[sf_pass_current].max_azimut = sgp_sats[s].azimut
- --Ahora vamos a ver donde termina de ser visible
- repeat
- jtime = jtime + const_julian_minute * sf_next_visible_precision * 0.2
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (s , jtime)
- until ( (not sgp_sats[s].visible) or (sgp_sats[s].elevacion < sf_sky.elevacion_minima))
- jtime = jtime - const_julian_minute * sf_next_visible_precision * 0.2
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (s , jtime)
- --apuntamos donde termina de verse
- sf_passes[sf_pass_current].fin_jt = SGP_UTC_to_Local(jtime)
- sf_passes[sf_pass_current].fin_elevacion = sgp_sats[s].elevacion
- sf_passes[sf_pass_current].fin_azimut = sgp_sats[s].azimut
- --lo dejamos todo como estaba (en el tiempo real), incluso la dirección, llamando dos veces
- SGP_calculateSun (sgp_time.ujtime - const_julian_minute)
- SGP_calculateSatellite (s , sgp_time.ujtime - const_julian_minute)
- SGP_calculateSun (sgp_time.ujtime)
- SGP_calculateSatellite (s , sgp_time.ujtime)
- local year, month, day, hour, minute, second = SGP_Julian_To_Date(sf_passes[sf_pass_current].ini_jt)
- sf_passes[sf_pass_current].linea = string.format ("%02d",day) .. "/" .. string.format ("%02d",month)
- .. "/" .. year .. " " .. string.format ("%02d",hour) .. ":" .. string.format("%02d",minute)
- .. " " .. string.format("%02d", sf_passes[sf_pass_current].ini_elevacion) .. " "
- .. SF_azimutToString(sf_passes[sf_pass_current].ini_azimut) .. " "
- year, month, day, hour, minute, second = SGP_Julian_To_Date(sf_passes[sf_pass_current].max_jt)
- sf_passes[sf_pass_current].linea = sf_passes[sf_pass_current].linea
- .. string.format ("%02d",hour) .. ":" .. string.format("%02d",minute)
- .. " " .. string.format("%02d", sf_passes[sf_pass_current].max_elevacion) .. " "
- .. SF_azimutToString(sf_passes[sf_pass_current].max_azimut) .. " "
- year, month, day, hour, minute, second = SGP_Julian_To_Date(sf_passes[sf_pass_current].fin_jt)
- sf_passes[sf_pass_current].linea = sf_passes[sf_pass_current].linea
- .. string.format ("%02d",hour) .. ":" .. string.format("%02d",minute)
- .. " " .. string.format("%02d", sf_passes[sf_pass_current].fin_elevacion) .. " "
- .. SF_azimutToString(sf_passes[sf_pass_current].fin_azimut)
- local c = math.floor ((90- sf_passes[sf_pass_current].max_elevacion)/90*12)
- SF_erase(8, 21+sf_pass_limit*10, 60)
- screen.print(8, 21+sf_pass_limit*10, sf_passes[sf_pass_current].linea , sf_palette[4+c])
- screen.waitvblankstart()
- screen.flip()
- SF_erase(8, 21+sf_pass_limit*10, 60)
- screen.print(8, 21+sf_pass_limit*10, sf_passes[sf_pass_current].linea , sf_palette[4+c])
- screen.waitvblankstart()
- screen.flip()
- return true
- end
- function SF_generatePassPathSky(num_sat)
- if sf_pass_current < 1 or sf_pass_current > sf_pass_limit then
- return
- end
- local jtime = SGP_Local_to_UTC(sf_passes[sf_pass_current].ini_jt)
- local jtime_fin = SGP_Local_to_UTC(sf_passes[sf_pass_current].fin_jt)
- local i = 0
- while jtime < jtime_fin and i < sf_pass_path.max do
- i = i + 1
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (num_sat , jtime)
- sf_pass_path[i].azimut = sgp_sats[num_sat].azimut
- sf_pass_path[i].elevacion = sgp_sats[num_sat].elevacion
- sf_pass_path[i].latitud = sgp_sats[num_sat].latitud
- sf_pass_path[i].longitud = sgp_sats[num_sat].longitud
- jtime = jtime + const_julian_minute * 0.5
- end
- sf_pass_path.longitud = i
- SGP_getCurrentTime()
- jtime = sgp_time.ujtime
- SGP_calculateSun (jtime-const_julian_minute)
- SGP_calculateSatellite (num_sat , jtime-const_julian_minute)
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (num_sat , jtime)
- end
- function SF_generateNextPassPathSky(num_sat)
- if sf_next_current < 1 or sf_next_current > sf_next_limit then
- return
- end
- local jtime = SGP_Local_to_UTC(sf_next_passes[sf_next_current].ini_jt)
- local jtime_fin = SGP_Local_to_UTC(sf_next_passes[sf_next_current].fin_jt)
- local i = 0
- while jtime < jtime_fin and i < sf_pass_path.max do
- i = i + 1
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (num_sat , jtime)
- sf_pass_path[i].azimut = sgp_sats[num_sat].azimut
- sf_pass_path[i].elevacion = sgp_sats[num_sat].elevacion
- sf_pass_path[i].latitud = sgp_sats[num_sat].latitud
- sf_pass_path[i].longitud = sgp_sats[num_sat].longitud
- jtime = jtime + const_julian_minute * 0.5
- end
- sf_pass_path.longitud = i
- SGP_getCurrentTime()
- jtime = sgp_time.ujtime
- SGP_calculateSun (jtime-const_julian_minute)
- SGP_calculateSatellite (num_sat , jtime-const_julian_minute)
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (num_sat , jtime)
- end
- function SF_drawSatPathSky()
- local i
- if sf_pass_path.longitud <= 0 then
- return
- end
- for i = 1, sf_pass_path.longitud do
- SF_drawPointSky (sf_pass_path[i].azimut,sf_pass_path[i].elevacion,sf_palette[8])
- end
- end
- function SF_drawSatPathMap()
- local i
- if sf_pass_path.longitud <= 0 then
- return
- end
- for i = 1, sf_pass_path.longitud do
- SF_drawPointMap (sf_pass_path[i].latitud,sf_pass_path[i].longitud,sf_color_white)
- end
- end
- function SF_drawBatLevel(x, y, color_fuente)
- local level = batt.percent()
- local life = batt.time()
- local horas, minutos
- if level < 0 or level > 100 then
- level = "--"
- end
- if life < 0 or (life/60) > 20 then
- horas = "--"
- minutos = "--"
- color = color_fuente
- else
- horas = string.format ("%.0f",life / 60)
- minutos = string.format ("%.2d",life % 60)
- if sf_vision_nocturna then
- color = color_fuente
- else
- if level < 50 then
- color = color.new(255,255 * level/50,0)
- else
- color = color.new(255*(1-((level-50)/50)),255,0)
- end
- end
- end
- screen.print(x, y, "Autonomia: " .. horas.. "h " .. minutos .. "' ".. " Carga: " .. level .. "%" , color)
- end
- function SF_drawTempLevel(x, y,color_fuente)
- local level = batt.temp()
- local color
- if level > -20 and level < 90 then
- color = color_fuente
- if not sf_vision_nocturna then
- if level < 30 then
- color = color.new(0,255,0)
- elseif level < 40 then
- color = color.new(255*((level-30)/10),255,0)
- elseif level < 50 then
- color = color.new(255,255*(1-((level-40)/10)),0)
- else
- color = color.new(255,0,0)
- end
- end
- else
- color = color_fuente
- level = "--"
- end
- screen.print(x, y, "Temperatura bateria: " .. level .. " C" , color)
- end
- function SF_drawMemLevel(x, y,color_fuente)
- --local kbytes = System.getFreeMemory()/1024
- local kbytes = gcinfo ()
- local color = color_fuente
- if not sf_vision_nocturna then
- if kbytes < 3000 then
- color = color.new(0,255,0)
- elseif kbytes < 4000 then
- color = color.new(255,255,0)
- else
- color = color.new(255,0,0)
- end
- end
- screen.print(x, y, "Memoria ocupada: " .. tostring(kbytes) .. " KB", color)
- end
- function SF_drawCrossSky(azimut, elevacion)
- if elevacion > 0 then
- screen.waitvblankstart()
- screen.flip()
- SF_drawBitmapSky(azimut, elevacion , bitmap_cruz,0,0,bitmap_cruz:width(),bitmap_cruz:height())
- screen.waitvblankstart()
- screen.flip()
- end
- end
- function SF_drawSatSky( num_sat )
- if sgp_sats[num_sat].no_calcular > 0 then
- return
- end
- if (sgp_sats[num_sat].elevacion > sf_sky.elevacion_minima) then
- if sgp_sats[num_sat].visible then
- SF_drawLineSky(sgp_sats[num_sat].azimut, sgp_sats[num_sat].elevacion, sf_sat_tails[num_sat][1].azimut, sf_sat_tails[num_sat][1].elevacion, sf_palette[1])
- if string.sub(sgp_sats[num_sat].nombre,1,7) == "IRIDIUM" then
- SF_drawSuperCrossSky(sgp_sats[num_sat].azimut, sgp_sats[num_sat].elevacion,sf_palette[1])
- else
- SF_drawSuperPointSky(sgp_sats[num_sat].azimut, sgp_sats[num_sat].elevacion,sf_palette[1])
- end
- if sf_sky.show.satelliteNames then
- SF_drawLabelSatsSky(sgp_sats[num_sat].azimut , sgp_sats[num_sat].elevacion , sgp_sats[num_sat].nombre, sf_palette[1])
- end
- else
- SF_drawLineSky(sgp_sats[num_sat].azimut, sgp_sats[num_sat].elevacion, sf_sat_tails[num_sat][1].azimut, sf_sat_tails[num_sat][1].elevacion, sf_palette[12])
- if string.sub(sgp_sats[num_sat].nombre,1,7) == "IRIDIUM" then
- SF_drawSuperCrossSky(sgp_sats[num_sat].azimut, sgp_sats[num_sat].elevacion,sf_palette[12])
- else
- SF_drawSuperPointSky(sgp_sats[num_sat].azimut, sgp_sats[num_sat].elevacion,sf_palette[12])
- end
- if sf_sky.show.satelliteNames then
- SF_drawLabelSatsSky(sgp_sats[num_sat].azimut , sgp_sats[num_sat].elevacion , sgp_sats[num_sat].nombre, sf_palette[12])
- end
- end
- if not sf_moving_sky then
- for i = 1, sf_tail_length-1 do
- if sf_sat_tails[num_sat][i].eclipsado then
- SF_drawLineSky(sf_sat_tails[num_sat][i].azimut, sf_sat_tails[num_sat][i].elevacion, sf_sat_tails[num_sat][i+1].azimut, sf_sat_tails[num_sat][i+1].elevacion, sf_palette[math.floor(12+(i/4))])
- else
- SF_drawLineSky(sf_sat_tails[num_sat][i].azimut, sf_sat_tails[num_sat][i].elevacion, sf_sat_tails[num_sat][i+1].azimut, sf_sat_tails[num_sat][i+1].elevacion, sf_palette[i])
- end
- end
- end
- sf_sat_tails[num_sat].step_current = sf_sat_tails[num_sat].step_current + 1
- if sf_sat_tails[num_sat].step_current >= sf_step_length then
- sf_sat_tails[num_sat].step_current = 0
- SF_AddPointToTail( num_sat, sgp_sats[num_sat].azimut, sgp_sats[num_sat].elevacion,sgp_sats[num_sat].eclipsado)
- end
- else
- if sgp_sats[num_sat].elevacion < 0 and sgp_sats[num_sat].elevacion_ant > 0 then
- SF_resetTail(num_sat)
- end
- end
- end
- function SF_drawMap ()
- --Polo Norte
- local fronterasX = {}
- local fronterasY = {}
- local color_fronteras
- if sf_vision_nocturna then
- color_fronteras = sf_palette[8]
- else
- color_fronteras = sf_palette[8]
- end
- fronterasX[1] = 19 fronterasY[1] = 38
- fronterasX[2] = 30 fronterasY[2] = 37
- fronterasX[3] = 41 fronterasY[3] = 38
- fronterasX[4] = 43 fronterasY[4] = 39
- fronterasX[5] = 49 fronterasY[5] = 36
- fronterasX[6] = 63 fronterasY[6] = 36
- fronterasX[7] = 80 fronterasY[7] = 35
- fronterasX[8] = 91 fronterasY[8] = 34
- fronterasX[9] = 102 fronterasY[9] = 31
- fronterasX[10] = 105 fronterasY[10] = 27
- fronterasX[11] = 100 fronterasY[11] = 27
- fronterasX[12] = 99 fronterasY[12] = 26
- fronterasX[13] = 107 fronterasY[13] = 25
- fronterasX[14] = 125 fronterasY[14] = 25
- fronterasX[15] = 138 fronterasY[15] = 23
- fronterasX[16] = 154 fronterasY[16] = 21
- fronterasX[17] = 171 fronterasY[17] = 19
- fronterasX[18] = 190 fronterasY[18] = 17
- fronterasX[19] = 201 fronterasY[19] = 16
- fronterasX[20] = 231 fronterasY[20] = 15
- fronterasX[21] = 235 fronterasY[21] = 17
- fronterasX[22] = 244 fronterasY[22] = 17
- fronterasX[23] = 256 fronterasY[23] = 17
- fronterasX[24] = 270 fronterasY[24] = 16
- fronterasX[25] = 280 fronterasY[25] = 15
- fronterasX[26] = 295 fronterasY[26] = 14
- fronterasX[27] = 316 fronterasY[27] = 14
- fronterasX[28] = 324 fronterasY[28] = 16
- fronterasX[29] = 333 fronterasY[29] = 17
- fronterasX[30] = 337 fronterasY[30] = 17
- fronterasX[31] = 342 fronterasY[31] = 16
- fronterasX[32] = 344 fronterasY[32] = 18
- fronterasX[33] = 364 fronterasY[33] = 19
- fronterasX[34] = 375 fronterasY[34] = 19
- fronterasX[35] = 383 fronterasY[35] = 18
- fronterasX[36] = 395 fronterasY[36] = 18
- fronterasX[37] = 399 fronterasY[37] = 19
- fronterasX[38] = 407 fronterasY[38] = 18
- fronterasX[39] = 413 fronterasY[39] = 19
- fronterasX[40] = 417 fronterasY[40] = 20
- fronterasX[41] = 424 fronterasY[41] = 19
- fronterasX[42] = 433 fronterasY[42] = 20
- fronterasX[43] = 444 fronterasY[43] = 20
- fronterasX[44] = 451 fronterasY[44] = 19
- fronterasX[45] = 462 fronterasY[45] = 19
- fronterasX[46] = 471 fronterasY[46] = 20
- fronterasX[47] = 474 fronterasY[47] = 20
- fronterasX[48] = 476 fronterasY[48] = 19
- fronterasX[49] = 479 fronterasY[49] = 19
- fronterasX[50] = 481 fronterasY[50] = 20
- fronterasX[51] = 497 fronterasY[51] = 20
- fronterasX[52] = 499 fronterasY[52] = 22
- fronterasX[53] = 501 fronterasY[53] = 24
- fronterasX[54] = 505 fronterasY[54] = 23
- fronterasX[55] = 507 fronterasY[55] = 21
- fronterasX[56] = 510 fronterasY[56] = 19
- fronterasX[57] = 511 fronterasY[57] = 21
- fronterasX[58] = 515 fronterasY[58] = 21
- fronterasX[59] = 523 fronterasY[59] = 20
- fronterasX[60] = 531 fronterasY[60] = 21
- fronterasX[61] = 536 fronterasY[61] = 21
- fronterasX[62] = 542 fronterasY[62] = 21
- fronterasX[63] = 546 fronterasY[63] = 21
- fronterasX[64] = 553 fronterasY[64] = 21
- fronterasX[65] = 561 fronterasY[65] = 21
- fronterasX[66] = 569 fronterasY[66] = 21
- fronterasX[67] = 577 fronterasY[67] = 22
- fronterasX[68] = 573 fronterasY[68] = 23
- fronterasX[69] = 577 fronterasY[69] = 25
- fronterasX[70] = 580 fronterasY[70] = 26
- fronterasX[71] = 585 fronterasY[71] = 27
- fronterasX[72] = 593 fronterasY[72] = 28
- fronterasX[73] = 593 fronterasY[73] = 31
- fronterasX[74] = 592 fronterasY[74] = 32
- fronterasX[75] = 597 fronterasY[75] = 30
- fronterasX[76] = 605 fronterasY[76] = 30
- fronterasX[77] = 613 fronterasY[77] = 29
- fronterasX[78] = 622 fronterasY[78] = 30
- fronterasX[79] = 626 fronterasY[79] = 32
- fronterasX[80] = 625 fronterasY[80] = 35
- fronterasX[81] = 630 fronterasY[81] = 36
- fronterasX[82] = 635 fronterasY[82] = 36
- fronterasX[83] = 639 fronterasY[83] = 37
- fronterasX[84] = 644 fronterasY[84] = 35
- fronterasX[85] = 651 fronterasY[85] = 34
- fronterasX[86] = 659 fronterasY[86] = 35
- fronterasX[87] = 668 fronterasY[87] = 34
- fronterasX[88] = 678 fronterasY[88] = 35
- fronterasX[89] = 686 fronterasY[89] = 36
- fronterasX[90] = 696 fronterasY[90] = 36
- fronterasX[91] = 707 fronterasY[91] = 37
- fronterasX[92] = 717 fronterasY[92] = 37
- fronterasX[93] = 719 fronterasY[93] = 37
- SF_drawPoliLine(fronterasX, fronterasY, 93, color_fronteras)
- fronterasX[1] = 2 fronterasY[1] = 36
- fronterasX[2] = 19 fronterasY[2] = 38
- SF_drawPoliLine(fronterasX, fronterasY, 2, color_fronteras)
- -- Islandia
- fronterasX[1] = 220 fronterasY[1] = 28
- fronterasX[2] = 226 fronterasY[2] = 29
- fronterasX[3] = 234 fronterasY[3] = 29
- fronterasX[4] = 239 fronterasY[4] = 29
- fronterasX[5] = 244 fronterasY[5] = 31
- fronterasX[6] = 249 fronterasY[6] = 36
- fronterasX[7] = 251 fronterasY[7] = 37
- fronterasX[8] = 248 fronterasY[8] = 38
- fronterasX[9] = 250 fronterasY[9] = 40
- fronterasX[10] = 251 fronterasY[10] = 38
- fronterasX[11] = 253 fronterasY[11] = 38
- fronterasX[12] = 255 fronterasY[12] = 39
- fronterasX[13] = 255 fronterasY[13] = 40
- fronterasX[14] = 250 fronterasY[14] = 42
- fronterasX[15] = 253 fronterasY[15] = 44
- fronterasX[16] = 254 fronterasY[16] = 43
- fronterasX[17] = 258 fronterasY[17] = 43
- fronterasX[18] = 257 fronterasY[18] = 45
- fronterasX[19] = 258 fronterasY[19] = 47
- fronterasX[20] = 256 fronterasY[20] = 49
- fronterasX[21] = 254 fronterasY[21] = 50
- fronterasX[22] = 255 fronterasY[22] = 51
- fronterasX[23] = 257 fronterasY[23] = 51
- fronterasX[24] = 260 fronterasY[24] = 53
- fronterasX[25] = 259 fronterasY[25] = 56
- fronterasX[26] = 261 fronterasY[26] = 58
- fronterasX[27] = 264 fronterasY[27] = 60
- fronterasX[28] = 266 fronterasY[28] = 60
- fronterasX[29] = 269 fronterasY[29] = 60
- fronterasX[30] = 271 fronterasY[30] = 62
- fronterasX[31] = 273 fronterasY[31] = 62
- fronterasX[32] = 276 fronterasY[32] = 58
- fronterasX[33] = 275 fronterasY[33] = 56
- fronterasX[34] = 277 fronterasY[34] = 55
- fronterasX[35] = 279 fronterasY[35] = 54
- fronterasX[36] = 281 fronterasY[36] = 51
- fronterasX[37] = 284 fronterasY[37] = 50
- fronterasX[38] = 290 fronterasY[38] = 49
- fronterasX[39] = 295 fronterasY[39] = 46
- fronterasX[40] = 300 fronterasY[40] = 45
- fronterasX[41] = 307 fronterasY[41] = 44
- fronterasX[42] = 315 fronterasY[42] = 42
- fronterasX[43] = 311 fronterasY[43] = 41
- fronterasX[44] = 309 fronterasY[44] = 40
- fronterasX[45] = 305 fronterasY[45] = 39
- fronterasX[46] = 308 fronterasY[46] = 38
- fronterasX[47] = 311 fronterasY[47] = 39
- fronterasX[48] = 313 fronterasY[48] = 40
- fronterasX[49] = 316 fronterasY[49] = 40
- fronterasX[50] = 311 fronterasY[50] = 38
- fronterasX[51] = 307 fronterasY[51] = 36
- fronterasX[52] = 310 fronterasY[52] = 35
- fronterasX[53] = 314 fronterasY[53] = 34
- fronterasX[54] = 322 fronterasY[54] = 33
- fronterasX[55] = 318 fronterasY[55] = 32
- fronterasX[56] = 321 fronterasY[56] = 31
- fronterasX[57] = 321 fronterasY[57] = 30
- fronterasX[58] = 318 fronterasY[58] = 29
- fronterasX[59] = 322 fronterasY[59] = 26
- fronterasX[60] = 322 fronterasY[60] = 25
- fronterasX[61] = 327 fronterasY[61] = 24
- fronterasX[62] = 331 fronterasY[62] = 22
- fronterasX[63] = 334 fronterasY[63] = 21
- fronterasX[64] = 325 fronterasY[64] = 21
- fronterasX[65] = 321 fronterasY[65] = 21
- fronterasX[66] = 318 fronterasY[66] = 20
- fronterasX[67] = 312 fronterasY[67] = 19
- fronterasX[68] = 308 fronterasY[68] = 18
- fronterasX[69] = 304 fronterasY[69] = 17
- fronterasX[70] = 300 fronterasY[70] = 18
- fronterasX[71] = 299 fronterasY[71] = 17
- fronterasX[72] = 294 fronterasY[72] = 17
- fronterasX[73] = 293 fronterasY[73] = 18
- fronterasX[74] = 291 fronterasY[74] = 18
- fronterasX[75] = 289 fronterasY[75] = 17
- fronterasX[76] = 287 fronterasY[76] = 18
- fronterasX[77] = 285 fronterasY[77] = 18
- fronterasX[78] = 283 fronterasY[78] = 19
- fronterasX[79] = 280 fronterasY[79] = 18
- fronterasX[80] = 279 fronterasY[80] = 18
- fronterasX[81] = 275 fronterasY[81] = 18
- fronterasX[82] = 271 fronterasY[82] = 18
- fronterasX[83] = 269 fronterasY[83] = 19
- fronterasX[84] = 266 fronterasY[84] = 19
- fronterasX[85] = 264 fronterasY[85] = 20
- fronterasX[86] = 261 fronterasY[86] = 20
- fronterasX[87] = 258 fronterasY[87] = 19
- fronterasX[88] = 260 fronterasY[88] = 22
- fronterasX[89] = 254 fronterasY[89] = 20
- fronterasX[90] = 252 fronterasY[90] = 21
- fronterasX[91] = 250 fronterasY[91] = 20
- fronterasX[92] = 245 fronterasY[92] = 20
- fronterasX[93] = 239 fronterasY[93] = 21
- fronterasX[94] = 233 fronterasY[94] = 22
- fronterasX[95] = 229 fronterasY[95] = 23
- fronterasX[96] = 224 fronterasY[96] = 24
- fronterasX[97] = 229 fronterasY[97] = 25
- fronterasX[98] = 224 fronterasY[98] = 26
- fronterasX[99] = 221 fronterasY[99] = 27
- fronterasX[100] = 214 fronterasY[100] = 27
- fronterasX[101] = 220 fronterasY[101] = 28
- SF_drawPoliLine(fronterasX, fronterasY, 101, color_fronteras)
- --America
- -- Africa, Arabia saudi e India
- -- China y Japon
- fronterasX[1] = 606 fronterasY[1] = 107
- fronterasX[2] = 602 fronterasY[2] = 109
- fronterasX[3] = 601 fronterasY[3] = 107
- fronterasX[4] = 598 fronterasY[4] = 107
- fronterasX[5] = 602 fronterasY[5] = 105
- fronterasX[6] = 608 fronterasY[6] = 100
- fronterasX[7] = 606 fronterasY[7] = 104
- fronterasX[8] = 607 fronterasY[8] = 105
- fronterasX[9] = 612 fronterasY[9] = 104
- fronterasX[10] = 615 fronterasY[10] = 104
- fronterasX[11] = 613 fronterasY[11] = 107
- fronterasX[12] = 615 fronterasY[12] = 108
- fronterasX[13] = 617 fronterasY[13] = 108
- fronterasX[14] = 617 fronterasY[14] = 111
- fronterasX[15] = 616 fronterasY[15] = 113
- fronterasX[16] = 618 fronterasY[16] = 114
- fronterasX[17] = 619 fronterasY[17] = 114
- fronterasX[18] = 624 fronterasY[18] = 111
- fronterasX[19] = 622 fronterasY[19] = 107
- fronterasX[20] = 620 fronterasY[20] = 104
- fronterasX[21] = 623 fronterasY[21] = 101
- fronterasX[22] = 628 fronterasY[22] = 96
- fronterasX[23] = 633 fronterasY[23] = 97
- fronterasX[24] = 640 fronterasY[24] = 92
- fronterasX[25] = 646 fronterasY[25] = 85
- fronterasX[26] = 647 fronterasY[26] = 79
- fronterasX[27] = 649 fronterasY[27] = 80
- fronterasX[28] = 649 fronterasY[28] = 85
- fronterasX[29] = 649 fronterasY[29] = 91
- fronterasX[30] = 648 fronterasY[30] = 95
- fronterasX[31] = 645 fronterasY[31] = 98
- fronterasX[32] = 646 fronterasY[32] = 101
- fronterasX[33] = 645 fronterasY[33] = 102
- fronterasX[34] = 645 fronterasY[34] = 105
- fronterasX[35] = 642 fronterasY[35] = 108
- fronterasX[36] = 638 fronterasY[36] = 108
- fronterasX[37] = 638 fronterasY[37] = 110
- fronterasX[38] = 635 fronterasY[38] = 112
- fronterasX[39] = 631 fronterasY[39] = 112
- fronterasX[40] = 628 fronterasY[40] = 113
- fronterasX[41] = 624 fronterasY[41] = 116
- fronterasX[42] = 624 fronterasY[42] = 118
- fronterasX[43] = 626 fronterasY[43] = 122
- fronterasX[44] = 628 fronterasY[44] = 118
- fronterasX[45] = 629 fronterasY[45] = 116
- fronterasX[46] = 630 fronterasY[46] = 118
- fronterasX[47] = 631 fronterasY[47] = 116
- fronterasX[48] = 633 fronterasY[48] = 116
- fronterasX[49] = 634 fronterasY[49] = 115
- fronterasX[50] = 636 fronterasY[50] = 116
- fronterasX[51] = 639 fronterasY[51] = 114
- fronterasX[52] = 641 fronterasY[52] = 114
- fronterasX[53] = 644 fronterasY[53] = 112
- fronterasX[54] = 647 fronterasY[54] = 111
- fronterasX[55] = 647 fronterasY[55] = 108
- fronterasX[56] = 649 fronterasY[56] = 105
- fronterasX[57] = 649 fronterasY[57] = 103
- fronterasX[58] = 647 fronterasY[58] = 101
- fronterasX[59] = 647 fronterasY[59] = 99
- fronterasX[60] = 646 fronterasY[60] = 98
- fronterasX[61] = 649 fronterasY[61] = 98
- fronterasX[62] = 652 fronterasY[62] = 100
- fronterasX[63] = 653 fronterasY[63] = 97
- fronterasX[64] = 657 fronterasY[64] = 96
- fronterasX[65] = 652 fronterasY[65] = 94
- fronterasX[66] = 649 fronterasY[66] = 91
- fronterasX[67] = 652 fronterasY[67] = 89
- fronterasX[68] = 651 fronterasY[68] = 87
- fronterasX[69] = 652 fronterasY[69] = 84
- fronterasX[70] = 654 fronterasY[70] = 84
- fronterasX[71] = 653 fronterasY[71] = 81
- fronterasX[72] = 652 fronterasY[72] = 79
- fronterasX[73] = 653 fronterasY[73] = 76
- fronterasX[74] = 651 fronterasY[74] = 75
- fronterasX[75] = 648 fronterasY[75] = 76
- fronterasX[76] = 645 fronterasY[76] = 74
- fronterasX[77] = 642 fronterasY[77] = 75
- fronterasX[78] = 640 fronterasY[78] = 72
- fronterasX[79] = 641 fronterasY[79] = 69
- fronterasX[80] = 646 fronterasY[80] = 66
- fronterasX[81] = 653 fronterasY[81] = 64
- fronterasX[82] = 662 fronterasY[82] = 63
- fronterasX[83] = 670 fronterasY[83] = 63
- fronterasX[84] = 676 fronterasY[84] = 62
- fronterasX[85] = 682 fronterasY[85] = 59
- fronterasX[86] = 686 fronterasY[86] = 59
- fronterasX[87] = 688 fronterasY[87] = 61
- fronterasX[88] = 686 fronterasY[88] = 64
- fronterasX[89] = 681 fronterasY[89] = 67
- fronterasX[90] = 678 fronterasY[90] = 70
- fronterasX[91] = 677 fronterasY[91] = 72
- fronterasX[92] = 678 fronterasY[92] = 75
- fronterasX[93] = 680 fronterasY[93] = 79
- fronterasX[94] = 683 fronterasY[94] = 79
- fronterasX[95] = 683 fronterasY[95] = 77
- fronterasX[96] = 686 fronterasY[96] = 77
- fronterasX[97] = 687 fronterasY[97] = 74
- fronterasX[98] = 690 fronterasY[98] = 74
- fronterasX[99] = 692 fronterasY[99] = 72
- fronterasX[100] = 693 fronterasY[100] = 70
- fronterasX[101] = 693 fronterasY[101] = 68
- fronterasX[102] = 692 fronterasY[102] = 66
- fronterasX[103] = 694 fronterasY[103] = 65
- fronterasX[104] = 695 fronterasY[104] = 63
- fronterasX[105] = 698 fronterasY[105] = 63
- fronterasX[106] = 701 fronterasY[106] = 61
- fronterasX[107] = 705 fronterasY[107] = 62
- fronterasX[108] = 712 fronterasY[108] = 61
- fronterasX[109] = 717 fronterasY[109] = 59
- fronterasX[110] = 719 fronterasY[110] = 59
- SF_drawPoliLine(fronterasX, fronterasY, 110, color_fronteras)
- fronterasX[1] = 609 fronterasY[1] = 109
- fronterasX[2] = 606 fronterasY[2] = 107
- SF_drawPoliLine(fronterasX, fronterasY, 2, color_fronteras)
- -- Europa
- -- Mediterraneo
- fronterasX[1] = 432 fronterasY[1] = 92
- fronterasX[2] = 429 fronterasY[2] = 91
- fronterasX[3] = 433 fronterasY[3] = 89
- fronterasX[4] = 437 fronterasY[4] = 88
- fronterasX[5] = 436 fronterasY[5] = 90
- fronterasX[6] = 437 fronterasY[6] = 92
- fronterasX[7] = 434 fronterasY[7] = 92
- fronterasX[8] = 437 fronterasY[8] = 94
- fronterasX[9] = 441 fronterasY[9] = 97
- fronterasX[10] = 443 fronterasY[10] = 99
- fronterasX[11] = 440 fronterasY[11] = 101
- fronterasX[12] = 433 fronterasY[12] = 101
- fronterasX[13] = 429 fronterasY[13] = 99
- fronterasX[14] = 425 fronterasY[14] = 100
- fronterasX[15] = 420 fronterasY[15] = 100
- fronterasX[16] = 418 fronterasY[16] = 102
- fronterasX[17] = 413 fronterasY[17] = 103
- fronterasX[18] = 412 fronterasY[18] = 104
- fronterasX[19] = 412 fronterasY[19] = 106
- fronterasX[20] = 411 fronterasY[20] = 108
- fronterasX[21] = 413 fronterasY[21] = 109
- fronterasX[22] = 414 fronterasY[22] = 110
- fronterasX[23] = 417 fronterasY[23] = 110
- fronterasX[24] = 419 fronterasY[24] = 110
- fronterasX[25] = 422 fronterasY[25] = 110
- fronterasX[26] = 424 fronterasY[26] = 109
- fronterasX[27] = 426 fronterasY[27] = 110
- fronterasX[28] = 428 fronterasY[28] = 109
- fronterasX[29] = 432 fronterasY[29] = 111
- fronterasX[30] = 431 fronterasY[30] = 113
- fronterasX[31] = 430 fronterasY[31] = 116
- fronterasX[32] = 429 fronterasY[32] = 118
- fronterasX[33] = 428 fronterasY[33] = 120
- fronterasX[34] = 424 fronterasY[34] = 121
- fronterasX[35] = 422 fronterasY[35] = 123
- fronterasX[36] = 421 fronterasY[36] = 121
- fronterasX[37] = 419 fronterasY[37] = 121
- fronterasX[38] = 415 fronterasY[38] = 120
- fronterasX[39] = 410 fronterasY[39] = 119
- fronterasX[40] = 404 fronterasY[40] = 117
- fronterasX[41] = 402 fronterasY[41] = 117
- fronterasX[42] = 400 fronterasY[42] = 118
- fronterasX[43] = 399 fronterasY[43] = 120
- fronterasX[44] = 399 fronterasY[44] = 122
- fronterasX[45] = 397 fronterasY[45] = 122
- fronterasX[46] = 390 fronterasY[46] = 120
- fronterasX[47] = 388 fronterasY[47] = 118
- fronterasX[48] = 385 fronterasY[48] = 117
- fronterasX[49] = 380 fronterasY[49] = 116
- fronterasX[50] = 379 fronterasY[50] = 115
- fronterasX[51] = 381 fronterasY[51] = 113
- fronterasX[52] = 380 fronterasY[52] = 111
- fronterasX[53] = 380 fronterasY[53] = 109
- fronterasX[54] = 378 fronterasY[54] = 108
- fronterasX[55] = 376 fronterasY[55] = 109
- fronterasX[56] = 373 fronterasY[56] = 109
- fronterasX[57] = 371 fronterasY[57] = 109
- fronterasX[58] = 367 fronterasY[58] = 109
- fronterasX[59] = 365 fronterasY[59] = 109
- fronterasX[60] = 362 fronterasY[60] = 111
- fronterasX[61] = 359 fronterasY[61] = 112
- fronterasX[62] = 356 fronterasY[62] = 112
- fronterasX[63] = 353 fronterasY[63] = 113
- fronterasX[64] = 352 fronterasY[64] = 112
- fronterasX[65] = 350 fronterasY[65] = 111
- SF_drawPoliLine(fronterasX, fronterasY, 65, color_fronteras)
- fronterasX[1] = 428 fronterasY[1] = 94
- fronterasX[2] = 432 fronterasY[2] = 92
- SF_drawPoliLine(fronterasX, fronterasY, 2, color_fronteras)
- -- Australia
- fronterasX[1] = 649 fronterasY[1] = 208
- fronterasX[2] = 648 fronterasY[2] = 212
- fronterasX[3] = 648 fronterasY[3] = 217
- fronterasX[4] = 645 fronterasY[4] = 220
- fronterasX[5] = 642 fronterasY[5] = 218
- fronterasX[6] = 639 fronterasY[6] = 216
- fronterasX[7] = 636 fronterasY[7] = 214
- fronterasX[8] = 637 fronterasY[8] = 213
- fronterasX[9] = 639 fronterasY[9] = 213
- fronterasX[10] = 639 fronterasY[10] = 212
- fronterasX[11] = 637 fronterasY[11] = 211
- fronterasX[12] = 638 fronterasY[12] = 209
- fronterasX[13] = 638 fronterasY[13] = 207
- fronterasX[14] = 633 fronterasY[14] = 208
- fronterasX[15] = 630 fronterasY[15] = 207
- fronterasX[16] = 628 fronterasY[16] = 207
- fronterasX[17] = 629 fronterasY[17] = 209
- fronterasX[18] = 625 fronterasY[18] = 207
- fronterasX[19] = 625 fronterasY[19] = 210
- fronterasX[20] = 623 fronterasY[20] = 213
- fronterasX[21] = 620 fronterasY[21] = 213
- fronterasX[22] = 618 fronterasY[22] = 212
- fronterasX[23] = 615 fronterasY[23] = 213
- fronterasX[24] = 612 fronterasY[24] = 216
- fronterasX[25] = 611 fronterasY[25] = 218
- fronterasX[26] = 609 fronterasY[26] = 217
- fronterasX[27] = 607 fronterasY[27] = 219
- fronterasX[28] = 608 fronterasY[28] = 221
- fronterasX[29] = 605 fronterasY[29] = 224
- fronterasX[30] = 600 fronterasY[30] = 225
- fronterasX[31] = 594 fronterasY[31] = 227
- fronterasX[32] = 591 fronterasY[32] = 228
- fronterasX[33] = 590 fronterasY[33] = 233
- fronterasX[34] = 590 fronterasY[34] = 237
- fronterasX[35] = 593 fronterasY[35] = 243
- fronterasX[36] = 594 fronterasY[36] = 247
- fronterasX[37] = 595 fronterasY[37] = 251
- fronterasX[38] = 593 fronterasY[38] = 254
- fronterasX[39] = 597 fronterasY[39] = 255
- fronterasX[40] = 601 fronterasY[40] = 253
- fronterasX[41] = 607 fronterasY[41] = 252
- fronterasX[42] = 612 fronterasY[42] = 251
- fronterasX[43] = 618 fronterasY[43] = 249
- fronterasX[44] = 623 fronterasY[44] = 248
- fronterasX[45] = 629 fronterasY[45] = 248
- fronterasX[46] = 632 fronterasY[46] = 250
- fronterasX[47] = 634 fronterasY[47] = 252
- fronterasX[48] = 636 fronterasY[48] = 254
- fronterasX[49] = 638 fronterasY[49] = 252
- fronterasX[50] = 640 fronterasY[50] = 251
- fronterasX[51] = 639 fronterasY[51] = 254
- fronterasX[52] = 638 fronterasY[52] = 257
- fronterasX[53] = 641 fronterasY[53] = 258
- fronterasX[54] = 642 fronterasY[54] = 257
- fronterasX[55] = 643 fronterasY[55] = 258
- fronterasX[56] = 645 fronterasY[56] = 261
- fronterasX[57] = 647 fronterasY[57] = 262
- fronterasX[58] = 650 fronterasY[58] = 262
- fronterasX[59] = 652 fronterasY[59] = 262
- fronterasX[60] = 654 fronterasY[60] = 261
- fronterasX[61] = 656 fronterasY[61] = 262
- fronterasX[62] = 660 fronterasY[62] = 261
- fronterasX[63] = 662 fronterasY[63] = 261
- fronterasX[64] = 664 fronterasY[64] = 260
- fronterasX[65] = 665 fronterasY[65] = 258
- fronterasX[66] = 666 fronterasY[66] = 255
- fronterasX[67] = 668 fronterasY[67] = 251
- fronterasX[68] = 671 fronterasY[68] = 247
- fronterasX[69] = 672 fronterasY[69] = 241
- fronterasX[70] = 671 fronterasY[70] = 236
- fronterasX[71] = 667 fronterasY[71] = 232
- fronterasX[72] = 665 fronterasY[72] = 229
- fronterasX[73] = 662 fronterasY[73] = 226
- fronterasX[74] = 658 fronterasY[74] = 223
- fronterasX[75] = 657 fronterasY[75] = 219
- fronterasX[76] = 656 fronterasY[76] = 215
- fronterasX[77] = 655 fronterasY[77] = 213
- fronterasX[78] = 652 fronterasY[78] = 212
- fronterasX[79] = 652 fronterasY[79] = 209
- fronterasX[80] = 651 fronterasY[80] = 208
- fronterasX[81] = 650 fronterasY[81] = 206
- fronterasX[82] = 649 fronterasY[82] = 208
- SF_drawPoliLine(fronterasX, fronterasY, 82, color_fronteras)
- -- Antartida
- fronterasX[1] = 13 fronterasY[1] = 341
- fronterasX[2] = 23 fronterasY[2] = 341
- fronterasX[3] = 36 fronterasY[3] = 340
- fronterasX[4] = 38 fronterasY[4] = 338
- fronterasX[5] = 46 fronterasY[5] = 340
- fronterasX[6] = 53 fronterasY[6] = 338
- fronterasX[7] = 62 fronterasY[7] = 336
- fronterasX[8] = 77 fronterasY[8] = 335
- fronterasX[9] = 93 fronterasY[9] = 334
- fronterasX[10] = 97 fronterasY[10] = 333
- fronterasX[11] = 101 fronterasY[11] = 331
- fronterasX[12] = 108 fronterasY[12] = 333
- fronterasX[13] = 112 fronterasY[13] = 331
- fronterasX[14] = 118 fronterasY[14] = 333
- fronterasX[15] = 128 fronterasY[15] = 333
- fronterasX[16] = 135 fronterasY[16] = 333
- fronterasX[17] = 137 fronterasY[17] = 331
- fronterasX[18] = 142 fronterasY[18] = 333
- fronterasX[19] = 149 fronterasY[19] = 333
- fronterasX[20] = 150 fronterasY[20] = 331
- fronterasX[21] = 163 fronterasY[21] = 329
- fronterasX[22] = 165 fronterasY[22] = 332
- fronterasX[23] = 178 fronterasY[23] = 331
- fronterasX[24] = 187 fronterasY[24] = 332
- fronterasX[25] = 195 fronterasY[25] = 332
- fronterasX[26] = 200 fronterasY[26] = 330
- fronterasX[27] = 202 fronterasY[27] = 330
- fronterasX[28] = 203 fronterasY[28] = 332
- fronterasX[29] = 207 fronterasY[29] = 332
- fronterasX[30] = 204 fronterasY[30] = 330
- fronterasX[31] = 211 fronterasY[31] = 330
- fronterasX[32] = 212 fronterasY[32] = 330
- fronterasX[33] = 207 fronterasY[33] = 328
- fronterasX[34] = 205 fronterasY[34] = 326
- fronterasX[35] = 208 fronterasY[35] = 323
- fronterasX[36] = 213 fronterasY[36] = 327
- fronterasX[37] = 215 fronterasY[37] = 327
- fronterasX[38] = 213 fronterasY[38] = 325
- fronterasX[39] = 213 fronterasY[39] = 322
- fronterasX[40] = 219 fronterasY[40] = 323
- fronterasX[41] = 222 fronterasY[41] = 328
- fronterasX[42] = 220 fronterasY[42] = 330
- fronterasX[43] = 214 fronterasY[43] = 331
- fronterasX[44] = 221 fronterasY[44] = 331
- fronterasX[45] = 224 fronterasY[45] = 330
- fronterasX[46] = 224 fronterasY[46] = 327
- fronterasX[47] = 222 fronterasY[47] = 324
- fronterasX[48] = 224 fronterasY[48] = 323
- fronterasX[49] = 223 fronterasY[49] = 321
- fronterasX[50] = 224 fronterasY[50] = 320
- fronterasX[51] = 222 fronterasY[51] = 319
- fronterasX[52] = 229 fronterasY[52] = 315
- fronterasX[53] = 234 fronterasY[53] = 313
- fronterasX[54] = 240 fronterasY[54] = 311
- fronterasX[55] = 247 fronterasY[55] = 312
- fronterasX[56] = 242 fronterasY[56] = 314
- fronterasX[57] = 237 fronterasY[57] = 316
- fronterasX[58] = 235 fronterasY[58] = 318
- fronterasX[59] = 232 fronterasY[59] = 318
- fronterasX[60] = 229 fronterasY[60] = 319
- fronterasX[61] = 229 fronterasY[61] = 321
- fronterasX[62] = 231 fronterasY[62] = 323
- fronterasX[63] = 235 fronterasY[63] = 325
- fronterasX[64] = 238 fronterasY[64] = 327
- fronterasX[65] = 239 fronterasY[65] = 329
- fronterasX[66] = 237 fronterasY[66] = 333
- fronterasX[67] = 235 fronterasY[67] = 335
- fronterasX[68] = 264 fronterasY[68] = 340
- fronterasX[69] = 288 fronterasY[69] = 341
- fronterasX[70] = 303 fronterasY[70] = 338
- fronterasX[71] = 312 fronterasY[71] = 335
- fronterasX[72] = 313 fronterasY[72] = 334
- fronterasX[73] = 316 fronterasY[73] = 334
- fronterasX[74] = 325 fronterasY[74] = 331
- fronterasX[75] = 331 fronterasY[75] = 330
- fronterasX[76] = 335 fronterasY[76] = 329
- fronterasX[77] = 337 fronterasY[77] = 328
- fronterasX[78] = 341 fronterasY[78] = 327
- fronterasX[79] = 345 fronterasY[79] = 329
- fronterasX[80] = 348 fronterasY[80] = 326
- fronterasX[81] = 349 fronterasY[81] = 326
- fronterasX[82] = 351 fronterasY[82] = 328
- fronterasX[83] = 355 fronterasY[83] = 328
- fronterasX[84] = 355 fronterasY[84] = 326
- fronterasX[85] = 356 fronterasY[85] = 326
- fronterasX[86] = 359 fronterasY[86] = 329
- fronterasX[87] = 362 fronterasY[87] = 327
- fronterasX[88] = 364 fronterasY[88] = 326
- fronterasX[89] = 370 fronterasY[89] = 326
- fronterasX[90] = 385 fronterasY[90] = 325
- fronterasX[91] = 403 fronterasY[91] = 326
- fronterasX[92] = 421 fronterasY[92] = 323
- fronterasX[93] = 427 fronterasY[93] = 321
- fronterasX[94] = 432 fronterasY[94] = 324
- fronterasX[95] = 438 fronterasY[95] = 325
- fronterasX[96] = 440 fronterasY[96] = 322
- fronterasX[97] = 451 fronterasY[97] = 321
- fronterasX[98] = 461 fronterasY[98] = 319
- fronterasX[99] = 465 fronterasY[99] = 317
- fronterasX[100] = 471 fronterasY[100] = 317
- fronterasX[101] = 478 fronterasY[101] = 320
- fronterasX[102] = 494 fronterasY[102] = 321
- fronterasX[103] = 499 fronterasY[103] = 321
- fronterasX[104] = 500 fronterasY[104] = 327
- fronterasX[105] = 499 fronterasY[105] = 329
- fronterasX[106] = 503 fronterasY[106] = 329
- fronterasX[107] = 508 fronterasY[107] = 325
- fronterasX[108] = 516 fronterasY[108] = 322
- fronterasX[109] = 531 fronterasY[109] = 319
- fronterasX[110] = 543 fronterasY[110] = 319
- fronterasX[111] = 553 fronterasY[111] = 317
- fronterasX[112] = 567 fronterasY[112] = 316
- fronterasX[113] = 575 fronterasY[113] = 317
- fronterasX[114] = 582 fronterasY[114] = 319
- fronterasX[115] = 588 fronterasY[115] = 316
- fronterasX[116] = 593 fronterasY[116] = 316
- fronterasX[117] = 597 fronterasY[117] = 318
- fronterasX[118] = 603 fronterasY[118] = 319
- fronterasX[119] = 616 fronterasY[119] = 318
- fronterasX[120] = 623 fronterasY[120] = 319
- fronterasX[121] = 633 fronterasY[121] = 317
- fronterasX[122] = 634 fronterasY[122] = 314
- fronterasX[123] = 637 fronterasY[123] = 317
- fronterasX[124] = 648 fronterasY[124] = 319
- fronterasX[125] = 664 fronterasY[125] = 323
- fronterasX[126] = 679 fronterasY[126] = 325
- fronterasX[127] = 701 fronterasY[127] = 328
- fronterasX[128] = 704 fronterasY[128] = 329
- fronterasX[129] = 707 fronterasY[129] = 329
- fronterasX[130] = 708 fronterasY[130] = 330
- fronterasX[131] = 705 fronterasY[131] = 332
- fronterasX[132] = 700 fronterasY[132] = 334
- fronterasX[133] = 695 fronterasY[133] = 335
- fronterasX[134] = 692 fronterasY[134] = 338
- fronterasX[135] = 694 fronterasY[135] = 341
- fronterasX[136] = 699 fronterasY[136] = 342
- fronterasX[137] = 700 fronterasY[137] = 340
- fronterasX[138] = 706 fronterasY[138] = 342
- fronterasX[139] = 713 fronterasY[139] = 342
- fronterasX[140] = 719 fronterasY[140] = 342
- SF_drawPoliLine(fronterasX, fronterasY, 140, color_fronteras)
- fronterasX[1] = 2 fronterasY[1] = 341
- fronterasX[2] = 13 fronterasY[2] = 341
- SF_drawPoliLine(fronterasX, fronterasY, 2, color_fronteras)
- -- Inglaterra
- fronterasX[1] = 363 fronterasY[1] = 81
- fronterasX[2] = 364 fronterasY[2] = 79
- fronterasX[3] = 364 fronterasY[3] = 77
- fronterasX[4] = 362 fronterasY[4] = 77
- fronterasX[5] = 361 fronterasY[5] = 75
- fronterasX[6] = 359 fronterasY[6] = 74
- fronterasX[7] = 358 fronterasY[7] = 72
- fronterasX[8] = 355 fronterasY[8] = 70
- fronterasX[9] = 357 fronterasY[9] = 68
- fronterasX[10] = 356 fronterasY[10] = 67
- fronterasX[11] = 353 fronterasY[11] = 68
- fronterasX[12] = 354 fronterasY[12] = 66
- fronterasX[13] = 355 fronterasY[13] = 65
- fronterasX[14] = 352 fronterasY[14] = 65
- fronterasX[15] = 350 fronterasY[15] = 67
- fronterasX[16] = 349 fronterasY[16] = 68
- fronterasX[17] = 349 fronterasY[17] = 70
- fronterasX[18] = 352 fronterasY[18] = 72
- fronterasX[19] = 354 fronterasY[19] = 73
- fronterasX[20] = 355 fronterasY[20] = 75
- fronterasX[21] = 353 fronterasY[21] = 77
- fronterasX[22] = 351 fronterasY[22] = 80
- fronterasX[23] = 355 fronterasY[23] = 79
- fronterasX[24] = 351 fronterasY[24] = 82
- fronterasX[25] = 358 fronterasY[25] = 81
- fronterasX[26] = 363 fronterasY[26] = 81
- SF_drawPoliLine(fronterasX, fronterasY, 26, color_fronteras)
- fronterasX[1] = 348 fronterasY[1] = 77
- fronterasX[2] = 349 fronterasY[2] = 73
- fronterasX[3] = 347 fronterasY[3] = 72
- fronterasX[4] = 346 fronterasY[4] = 73
- fronterasX[5] = 344 fronterasY[5] = 74
- fronterasX[6] = 342 fronterasY[6] = 74
- fronterasX[7] = 340 fronterasY[7] = 75
- fronterasX[8] = 342 fronterasY[8] = 77
- fronterasX[9] = 341 fronterasY[9] = 78
- fronterasX[10] = 342 fronterasY[10] = 79
- fronterasX[11] = 348 fronterasY[11] = 77
- SF_drawPoliLine(fronterasX, fronterasY, 11, color_fronteras)
- -- Madagascar
- fronterasX[1] = 455 fronterasY[1] = 213
- fronterasX[2] = 450 fronterasY[2] = 216
- fronterasX[3] = 448 fronterasY[3] = 220
- fronterasX[4] = 447 fronterasY[4] = 226
- fronterasX[5] = 447 fronterasY[5] = 232
- fronterasX[6] = 449 fronterasY[6] = 235
- fronterasX[7] = 454 fronterasY[7] = 234
- fronterasX[8] = 457 fronterasY[8] = 226
- fronterasX[9] = 460 fronterasY[9] = 217
- fronterasX[10] = 460 fronterasY[10] = 211
- fronterasX[11] = 459 fronterasY[11] = 209
- fronterasX[12] = 455 fronterasY[12] = 213
- SF_drawPoliLine(fronterasX, fronterasY, 12, color_fronteras)
- --Islandia
- fronterasX[1] = 316 fronterasY[1] = 53
- fronterasX[2] = 321 fronterasY[2] = 55
- fronterasX[3] = 327 fronterasY[3] = 53
- fronterasX[4] = 331 fronterasY[4] = 53
- fronterasX[5] = 333 fronterasY[5] = 51
- fronterasX[6] = 328 fronterasY[6] = 49
- fronterasX[7] = 323 fronterasY[7] = 50
- fronterasX[8] = 319 fronterasY[8] = 51
- fronterasX[9] = 316 fronterasY[9] = 49
- fronterasX[10] = 313 fronterasY[10] = 51
- fronterasX[11] = 316 fronterasY[11] = 53
- SF_drawPoliLine(fronterasX, fronterasY, 11, color_fronteras)
- --Indonesia
- -- Nueva Zelanda
- fronterasX[1] = 703 fronterasY[1] = 274
- fronterasX[2] = 708 fronterasY[2] = 270
- fronterasX[3] = 713 fronterasY[3] = 267
- fronterasX[4] = 715 fronterasY[4] = 266
- fronterasX[5] = 714 fronterasY[5] = 270
- fronterasX[6] = 712 fronterasY[6] = 271
- fronterasX[7] = 710 fronterasY[7] = 274
- fronterasX[8] = 708 fronterasY[8] = 274
- fronterasX[9] = 708 fronterasY[9] = 277
- fronterasX[10] = 706 fronterasY[10] = 278
- fronterasX[11] = 704 fronterasY[11] = 279
- fronterasX[12] = 702 fronterasY[12] = 279
- fronterasX[13] = 700 fronterasY[13] = 278
- fronterasX[14] = 698 fronterasY[14] = 277
- fronterasX[15] = 703 fronterasY[15] = 274
- SF_drawPoliLine(fronterasX, fronterasY, 15, color_fronteras)
- fronterasX[1] = 717 fronterasY[1] = 266
- fronterasX[2] = 717 fronterasY[2] = 265
- fronterasX[3] = 715 fronterasY[3] = 264
- fronterasX[4] = 713 fronterasY[4] = 264
- fronterasX[5] = 715 fronterasY[5] = 262
- fronterasX[6] = 716 fronterasY[6] = 261
- fronterasX[7] = 716 fronterasY[7] = 258
- fronterasX[8] = 713 fronterasY[8] = 256
- fronterasX[9] = 712 fronterasY[9] = 255
- fronterasX[10] = 715 fronterasY[10] = 255
- fronterasX[11] = 717 fronterasY[11] = 256
- fronterasX[12] = 718 fronterasY[12] = 259
- fronterasX[13] = 719 fronterasY[13] = 261
- fronterasX[14] = 719 fronterasY[14] = 261
- fronterasX[15] = 719 fronterasY[15] = 266
- fronterasX[16] = 717 fronterasY[16] = 269
- fronterasX[17] = 717 fronterasY[17] = 266
- SF_drawPoliLine(fronterasX, fronterasY, 17, color_fronteras)
- fronterasX[1] = 5 fronterasY[1] = 53
- fronterasX[2] = 8 fronterasY[2] = 51
- fronterasX[3] = 11 fronterasY[3] = 50
- fronterasX[4] = 12 fronterasY[4] = 49
- fronterasX[5] = 10 fronterasY[5] = 48
- fronterasX[6] = 7 fronterasY[6] = 48
- fronterasX[7] = 5 fronterasY[7] = 47
- fronterasX[8] = 3 fronterasY[8] = 47
- fronterasX[9] = 2 fronterasY[9] = 45
- SF_drawPoliLine(fronterasX, fronterasY, 9, color_fronteras)
- fronterasX[1] = 2 fronterasY[1] = 54
- fronterasX[2] = 5 fronterasY[2] = 53
- SF_drawPoliLine(fronterasX, fronterasY, 2, color_fronteras)
- fronterasX[1] = 245 fronterasY[1] = 81
- fronterasX[2] = 242 fronterasY[2] = 84
- fronterasX[3] = 241 fronterasY[3] = 86
- fronterasX[4] = 245 fronterasY[4] = 87
- fronterasX[5] = 248 fronterasY[5] = 86
- fronterasX[6] = 249 fronterasY[6] = 88
- fronterasX[7] = 251 fronterasY[7] = 87
- fronterasX[8] = 252 fronterasY[8] = 90
- fronterasX[9] = 254 fronterasY[9] = 89
- fronterasX[10] = 253 fronterasY[10] = 87
- fronterasX[11] = 251 fronterasY[11] = 84
- fronterasX[12] = 249 fronterasY[12] = 84
- fronterasX[13] = 246 fronterasY[13] = 82
- fronterasX[14] = 248 fronterasY[14] = 80
- fronterasX[15] = 246 fronterasY[15] = 80
- fronterasX[16] = 245 fronterasY[16] = 81
- SF_drawPoliLine(fronterasX, fronterasY, 16, color_fronteras)
- fronterasX[1] = 190 fronterasY[1] = 139
- fronterasX[2] = 192 fronterasY[2] = 138
- fronterasX[3] = 194 fronterasY[3] = 137
- fronterasX[4] = 197 fronterasY[4] = 139
- fronterasX[5] = 199 fronterasY[5] = 139
- fronterasX[6] = 201 fronterasY[6] = 141
- fronterasX[7] = 203 fronterasY[7] = 142
- fronterasX[8] = 205 fronterasY[8] = 143
- fronterasX[9] = 209 fronterasY[9] = 143
- fronterasX[10] = 206 fronterasY[10] = 141
- fronterasX[11] = 204 fronterasY[11] = 140
- fronterasX[12] = 201 fronterasY[12] = 140
- fronterasX[13] = 199 fronterasY[13] = 138
- fronterasX[14] = 196 fronterasY[14] = 137
- fronterasX[15] = 193 fronterasY[15] = 137
- fronterasX[16] = 192 fronterasY[16] = 138
- fronterasX[17] = 190 fronterasY[17] = 137
- fronterasX[18] = 189 fronterasY[18] = 138
- fronterasX[19] = 190 fronterasY[19] = 139
- SF_drawPoliLine(fronterasX, fronterasY, 19, color_fronteras)
- fronterasX[1] = 212 fronterasY[1] = 145
- fronterasX[2] = 214 fronterasY[2] = 143
- fronterasX[3] = 216 fronterasY[3] = 143
- fronterasX[4] = 218 fronterasY[4] = 145
- fronterasX[5] = 220 fronterasY[5] = 145
- fronterasX[6] = 222 fronterasY[6] = 146
- fronterasX[7] = 224 fronterasY[7] = 146
- fronterasX[8] = 227 fronterasY[8] = 147
- fronterasX[9] = 223 fronterasY[9] = 146
- fronterasX[10] = 218 fronterasY[10] = 146
- fronterasX[11] = 215 fronterasY[11] = 147
- fronterasX[12] = 212 fronterasY[12] = 147
- fronterasX[13] = 210 fronterasY[13] = 145
- fronterasX[14] = 212 fronterasY[14] = 145
- SF_drawPoliLine(fronterasX, fronterasY, 14, color_fronteras)
- local px, py = SF_LatLonToXY(sgp_location.lat, sgp_location.lon)
- draw.line(px-3,py, px+3, py, sf_palette[1])
- draw.line(px, py-3, px, py+3, sf_palette[1])
- end
- function SF_drawSatMap( num_sat )
- if string.sub(sgp_sats[num_sat].nombre,1,7) == "IRIDIUM" then
- if sf_vision_nocturna then
- if sgp_sats[num_sat].visible then
- SF_drawSuperCrossMap(sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_color_white )
- elseif sgp_sats[num_sat].eclipsado then
- SF_drawSuperCrossMap(sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_palette[12] )
- else
- SF_drawSuperCrossMap(sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_palette[4] )
- end
- else
- if sgp_sats[num_sat].visible then
- SF_drawSuperCrossMap(sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_color_white )
- elseif sgp_sats[num_sat].eclipsado then
- SF_drawSuperCrossMap(sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_palette[12] )
- else
- SF_drawSuperCrossMap(sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_palette[4] )
- end
- end
- else
- if sf_vision_nocturna then
- if sgp_sats[num_sat].visible then
- SF_drawSuperPointMap(sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_color_white )
- elseif sgp_sats[num_sat].eclipsado then
- SF_drawSuperPointMap(sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_palette[12] )
- else
- SF_drawSuperPointMap(sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_palette[1] )
- end
- else
- if sgp_sats[num_sat].visible then
- SF_drawSuperPointMap(sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_color_white )
- elseif sgp_sats[num_sat].eclipsado then
- SF_drawSuperPointMap(sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_palette[12] )
- else
- SF_drawSuperPointMap(sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_palette[1] )
- end
- end
- end
- if num_sat == sf_selected_sat then
- SF_drawSatPath (num_sat, 30)
- SF_drawTextMap(sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sgp_sats[num_sat].nombre, sf_palette[1] )
- end
- end
- function SF_drawSatPath (num_sat, minutos)
- if sgp_sat_number <= 0 then
- return
- end
- SGP_getCurrentTime()
- local jtime = sgp_time.ujtime
- local i
- local lat_ant, lon_ant
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (num_sat , jtime)
- lat_ant = sgp_sats[num_sat].latitud
- lon_ant = sgp_sats[num_sat].longitud
- for i = 1,minutos do
- SGP_calculateSun (jtime + const_julian_minute * i)
- SGP_calculateSatellite (num_sat , jtime + const_julian_minute * i)
- if math.abs (lon_ant-sgp_sats[num_sat].longitud) < 20 then
- if sf_vision_nocturna then
- if sgp_sats[num_sat].visible then
- SF_drawLineMap(lat_ant, lon_ant, sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_color_white )
- elseif sgp_sats[num_sat].eclipsado then
- SF_drawLineMap(lat_ant, lon_ant, sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_palette[12] )
- else
- SF_drawLineMap(lat_ant, lon_ant, sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_palette[4] )
- end
- else
- if sgp_sats[num_sat].visible then
- SF_drawLineMap(lat_ant, lon_ant, sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_color_white )
- elseif sgp_sats[num_sat].eclipsado then
- SF_drawLineMap(lat_ant, lon_ant, sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_palette[12] )
- else
- SF_drawLineMap(lat_ant, lon_ant, sgp_sats[num_sat].latitud,sgp_sats[num_sat].longitud, sf_palette[4] )
- end
- end
- end
- lat_ant = sgp_sats[num_sat].latitud
- lon_ant = sgp_sats[num_sat].longitud
- end
- SGP_calculateSun (jtime-const_julian_minute)
- SGP_calculateSatellite (num_sat , jtime-const_julian_minute)
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (num_sat , jtime)
- end
- function SF_drawPoliLine (x, y, points, color)
- local i
- for i = 1,points-1 do
- draw.line( x[i]*480/720, y[i]*272/360, x[i+1]*480/720, y[i+1]*272/360, color)
- end
- end
- function SF_erase(x, y, caracteres)
- draw.fillrect(x, y, 8*caracteres, 8, sf_color_black)
- end
- function SF_initTails()
- -- Estelas satelites
- sf_sat_tails = {}
- local i
- for i = 1, sgp_sat_number do
- sf_sat_tails[i] = {}
- sf_sat_tails[i].step_current = 0
- sf_sat_tails[i].marca_tiempo = 0.0
- for j = 1, sf_palette_len do
- sf_sat_tails[i][j] = {}
- sf_sat_tails[i][j].azimut = 0
- sf_sat_tails[i][j].elevacion = -1
- sf_sat_tails[i][j].eclipsado = false
- end
- SF_initTail(i)
- end
- end
- function SF_changePalette(red, green, blue)
- local i
- for i = 1 , sf_palette_len do
- sf_palette[i] = color.new(red * (1-((i-1)/sf_palette_len)), green * (1-((i-1)/sf_palette_len)), blue * (1-((i-1)/sf_palette_len)))
- end
- end
- function SF_initTail(sat)
- SGP_getCurrentTime()
- jtime = sgp_time.ujtime
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (sat , jtime)
- if sgp_sats[sat].elevacion < sf_sky.elevacion_minima then
- return
- end
- local step = const_julian_minute / sf_tail_length
- local jt = jtime
- local j
- for j = 1, sf_tail_length do
- SGP_calculateSun (jt)
- SGP_calculateSatellite (sat , jt)
- sf_sat_tails[sat][j].azimut = sgp_sats[sat].azimut
- sf_sat_tails[sat][j].elevacion = sgp_sats[sat].elevacion
- sf_sat_tails[sat][j].eclipsado = sgp_sats[sat].eclipsado
- jt = jt - step
- end
- SGP_calculateSun (jtime-const_julian_minute)
- SGP_calculateSatellite (sat , jtime-const_julian_minute)
- SGP_calculateSun (jtime)
- SGP_calculateSatellite (sat , jtime)
- sf_sat_tails[sat].marca_tiempo = jtime
- end
- function SF_redrawTails()
- local i
- for i = 1, sgp_sat_number do
- SF_initTail(i)
- end
- end
- function SF_resetTails()
- local i
- for i = 1, sgp_sat_number do
- SF_resetTail(i)
- end
- end
- function SF_resetTail(sat)
- if sf_sat_tails[sat][1].elevacion == -1 then
- return
- end
- sf_sat_tails[sat].step_current = 0
- sf_sat_tails[sat].marca_tiempo = 0.0
- local j
- for j = 1, sf_tail_length do
- sf_sat_tails[sat][j].azimut = 0
- sf_sat_tails[sat][j].elevacion = -1
- sf_sat_tails[sat][j].eclipsado = false
- end
- end
- function SF_AddPointToTail( num_sat, azimut, elevacion, eclipsado)
- local i = sf_tail_length - 1;
- if sgp_time.ujtime - sf_sat_tails[num_sat].marca_tiempo > const_julian_minute then
- screen.print(140,135,"Actualizando satelites...",sf_palette[8])
- screen.waitvblankstart()
- screen.flip()
- screen.print(140,135,"Actualizando satelites...",sf_palette[8])
- screen.waitvblankstart()
- screen.flip()
- SF_redrawTails()
- else
- while i > 0 do
- sf_sat_tails[num_sat][i+1].azimut = sf_sat_tails[num_sat][i].azimut
- sf_sat_tails[num_sat][i+1].elevacion = sf_sat_tails[num_sat][i].elevacion
- sf_sat_tails[num_sat][i+1].eclipsado = sf_sat_tails[num_sat][i].eclipsado
- i = i - 1
- end
- sf_sat_tails[num_sat][1].azimut = azimut
- sf_sat_tails[num_sat][1].elevacion = elevacion
- sf_sat_tails[num_sat][1].eclipsado = eclipsado
- sf_sat_tails[num_sat].marca_tiempo = sgp_time.ujtime
- end
- end
- function SND_azimut(azimut, elevacion)
- if elevacion > 80 then
- SND_wait("UP.wav",azimut, elevacion)
- else
- if ((0 <= azimut) and (azimut < 22.5 )) then
- SND_wait("N.wav",azimut, elevacion)
- elseif ((22.5 <= azimut) and (azimut < 67.5)) then
- SND_wait("NE.wav",azimut, elevacion)
- elseif ((67.5 <= azimut) and (azimut < 112.5)) then
- SND_wait("E.wav",azimut, elevacion)
- elseif ((112.5 <= azimut) and (azimut < 157.5)) then
- SND_wait("SE.wav",azimut, elevacion)
- elseif ((157.5 <= azimut) and (azimut < 202.5)) then
- SND_wait("S.wav",azimut, elevacion)
- elseif ((202.5 <= azimut) and (azimut < 247.5)) then
- SND_wait("SW.wav",azimut, elevacion)
- elseif ((247.5 <= azimut) and (azimut < 292.5)) then
- SND_wait("W.wav",azimut, elevacion)
- elseif ((292.5 <= azimut) and (azimut < 337.5)) then
- SND_wait("NW.wav",azimut, elevacion)
- elseif ((337.5 <= azimut) and (azimut < 360)) then
- SND_wait("N.wav",azimut, elevacion)
- end
- end
- end
- function SF_azimutToString(azimut)
- if ((0 <= azimut) and (azimut < 22.5 )) then
- return "N "
- elseif ((22.5 <= azimut) and (azimut < 67.5)) then
- return "NE"
- elseif ((67.5 <= azimut) and (azimut < 112.5)) then
- return "E "
- elseif ((112.5 <= azimut) and (azimut < 157.5)) then
- return "SE"
- elseif ((157.5 <= azimut) and (azimut < 202.5)) then
- return "S "
- elseif ((202.5 <= azimut) and (azimut < 247.5)) then
- return "SW"
- elseif ((247.5 <= azimut) and (azimut < 292.5)) then
- return "W "
- elseif ((292.5 <= azimut) and (azimut < 337.5)) then
- return "NW"
- elseif ((337.5 <= azimut) and (azimut < 360)) then
- return "N "
- end
- end
- function SND_wait( wave_file, azimut, elevacion)
- local snd = sound.load (wave_file,false)
- local voice = snd:play()
- voice:volume(255)
- local timer = timer.new()
- timer:reset(0)
- timer:start()
- if azimut ~= nil and elevacion ~= nil then
- SF_drawCrossSky(azimut, elevacion)
- end
- while timer:time() < 200 or voice:playing() do
- screen.waitvblankstart(5)
- screen.flip()
- end
- timer:stop()
- end
- function SND_playSoundsIfNeeded()
- if sf_primer_calculo then
- sf_elevacion_max_ant = sf_elevacion_max
- sf_noche_ant = sgp_location.noche
- sf_sun_elev_ant = sgp_sun.ele
- sf_moon_elev_ant = sgp_moon.ele
- else
- if sf_sun_elev_ant < -3 and sgp_sun.ele > -3 then
- SND_wait("sunrise.wav", nil, nil)
- end
- if sf_sun_elev_ant > 3 and sgp_sun.ele < 3 then
- SND_wait("sunset.wav", nil, nil)
- end
- if sf_sun_elev_ant < 0 and sgp_sun.ele > 0 then
- SND_wait("sunrise.wav", nil, nil)
- SGP_calculateSunRaiseTime()
- SGP_calculateSunSetTime()
- end
- if sf_sun_elev_ant > 0 and sgp_sun.ele < 0 then
- SND_wait("sunset.wav", nil, nil)
- SGP_calculateSunRaiseTime()
- SGP_calculateSunSetTime()
- end
- if sf_moon_elev_ant < -3 and sgp_moon.ele > -3 then
- SND_wait("moonrise.wav", nil, nil)
- end
- if sf_moon_elev_ant > 3 and sgp_moon.ele < 3 then
- SND_wait("moonset.wav", nil, nil)
- end
- if sf_moon_elev_ant < 0 and sgp_moon.ele > 0 then
- SND_wait("moonrise.wav", nil, nil)
- SGP_calculateMoonRaiseTime()
- SGP_calculateMoonSetTime()
- end
- if sf_moon_elev_ant > 0 and sgp_moon.ele < 0 then
- SND_wait("moonset.wav", nil, nil)
- SGP_calculateMoonRaiseTime()
- SGP_calculateMoonSetTime()
- end
- sf_sun_elev_ant = sgp_sun.ele
- sf_moon_elev_ant = sgp_moon.ele
- if sgp_location.noche and not sf_noche_ant then
- SND_wait("night_start.wav", nil, nil)
- SGP_calculateNightBegining()
- SGP_calculateNightEnding()
- sf_vision_nocturna = true
- SF_changePalette (sf_color_night.r,sf_color_night.g,sf_color_night.b)
- elseif not sgp_location.noche and sf_noche_ant then
- SND_wait("night_end.wav", nil, nil)
- SGP_calculateNightBegining()
- SGP_calculateNightEnding()
- sf_vision_nocturna = false
- SF_changePalette (sf_color_day.r,sf_color_day.g,sf_color_day.b)
- end
- sf_noche_ant = sgp_location.noche
- if sf_elevacion_max_ant < 80 and sf_elevacion_max > 80 then
- SND_wait("90.wav", sf_azimut_max, sf_elevacion_max)
- SND_azimut(sf_azimut_max, sf_elevacion_max)
- elseif sf_elevacion_max_ant < 60 and sf_elevacion_max > 60 then
- SND_wait("60.wav", sf_azimut_max, sf_elevacion_max)
- SND_azimut(sf_azimut_max, sf_elevacion_max)
- elseif sf_elevacion_max_ant < 30 and sf_elevacion_max > 30 then
- SND_wait("30.wav", sf_azimut_max, sf_elevacion_max)
- SND_azimut(sf_azimut_max, sf_elevacion_max)
- elseif sf_elevacion_max_ant < sf_sky.elevacion_minima and sf_elevacion_max > sf_sky.elevacion_minima then
- SND_wait("00.wav", sf_azimut_max, sf_elevacion_max)
- SND_azimut(sf_azimut_max, sf_elevacion_max)
- end
- sf_elevacion_max_ant = sf_elevacion_max
- end
- if sf_pass_limit > 0 and sf_pass_current > 0 and sf_pass_current <= sf_pass_limit then
- if sf_current_jtime_ant < sf_passes[sf_pass_current].ini_jt and sf_current_jtime > sf_passes[sf_pass_current].ini_jt then
- SND_wait("iss_start.wav",sf_passes[sf_pass_current].ini_azimut, sf_passes[sf_pass_current].ini_elevacion)
- SND_azimut(sf_passes[sf_pass_current].ini_azimut, sf_passes[sf_pass_current].ini_elevacion)
- elseif sf_current_jtime_ant < sf_passes[sf_pass_current].max_jt and sf_current_jtime > sf_passes[sf_pass_current].max_jt then
- SND_wait("iss_max.wav",sf_passes[sf_pass_current].max_azimut, sf_passes[sf_pass_current].max_elevacion)
- SND_azimut(sf_passes[sf_pass_current].max_azimut, sf_passes[sf_pass_current].max_elevacion)
- elseif sf_current_jtime_ant < sf_passes[sf_pass_current].fin_jt and sf_current_jtime > sf_passes[sf_pass_current].fin_jt then
- SND_wait("iss_end.wav",sf_passes[sf_pass_current].fin_azimut, sf_passes[sf_pass_current].fin_elevacion)
- SND_azimut(sf_passes[sf_pass_current].fin_azimut, sf_passes[sf_pass_current].fin_elevacion)
- end
- end
- end
- -- AQUI EMPIEZAN LOS CALCULOS SGP
- function SGP_Date_To_Julian(yr, mo, dy, hr, mi, se)
- return SGP_Julian_Date_of_Year(yr) + SGP_DOY(yr,mo,dy) + SGP_Fraction_of_Day(hr,mi,se)
- end
- function SGP_Julian_To_Date(jt)
- local day, month, year = SGP_calendarDate(jt,3)
- local hour, minutes, seconds, hundred_sec = SGP_timeOfDay(jt,3)
- return year, month, day, hour, minutes, seconds
- end
- function SGP_calendarDate(jd , res)
- local Z
- local month, day, year
- local A,B,C,D,E,F,alpha,factor
- factor = 0.5/const_secday/math.pow(10.0,res)
- F = (jd + 0.5) - math.floor(jd + 0.5)
- if (F + factor >= 1.0) then
- jd = jd + factor
- F = 0.0
- end
- Z = math.floor(jd + 0.5)
- if (Z < 2299161) then
- A = Z
- else
- alpha = math.floor((Z - 1867216.25)/36524.25)
- A = (Z + 1.0 + alpha) - math.floor(alpha/4.0)
- end
- B = A + 1524.0
- C = math.floor((B - 122.1)/365.25)
- D = math.floor(365.25 * C)
- E = math.floor((B - D)/30.6001)
- day = math.floor(B - D - math.floor(30.6001 * E) + F)
- if (E < 13.5) then
- month = math.floor((E - 1.0)+0.5)
- else
- month = math.floor((E - 13.0)+0.5)
- end
- if (month > 2.5) then
- year = math.floor((C - 4716.0)+0.5)
- else
- year = math.floor((C - 4715.0)+0.5)
- end
- return day, month , year
- end
- function SGP_timeOfDay(jd, res)
- local hr,mn,sec,hu
- local factor,time_,sc
- res = math.min(math.max(0.0,res),3.0)
- factor = math.pow(10.0,res)
- time_ = ((jd - 0.5)-math.floor(jd - 0.5))*const_secday
- time_ = math.floor(time_*factor+0.5)/factor
- hr = math.floor(time_/3600.0)
- time_ = time_ - (3600.0*hr)
- if (hr == 24) then
- hr = 0
- end
- mn = math.floor(time_/60.0)
- sc = time_ - (60.0*mn)
- hu = math.floor(((sc - math.floor(sc))*1000)+0.5)
- sec = math.floor(sc)
- return hr, mn, sec, hu
- end
- -- Calcula la fecha Juliana de Enero del año 0.0
- function SGP_Julian_Date_of_Year(year)
- local Y = year - 1
- local A = math.floor(year/100)
- local B = 2 - A + math.floor(A/4)
- return math.floor(365.25 * Y) + math.floor(30.6001 * 14) + 1720994.5 + B
- end
- function SGP_Julian_Date_of_Epoch(epoch)
- local year
- local day
- year = math.floor(epoch*0.001)
- if year < 57 then
- year = year + 2000
- else
- year = year + 1900
- end
- day = ((epoch*0.001) - math.floor(epoch*0.001))*1000
- return SGP_Julian_Date_of_Year(year) + day
- end
- function SGP_DOY(yr,mo,dy)
- local days = { 31,28,31,30,31,30,31,31,30,31,30,31 }
- local day = 0
- for i = 1,mo-1 do
- day = day + days[i]
- end
- day = day + dy
- if ((yr % 4) == 0) and (((yr % 100) ~= 0) or ((yr % 400) == 0)) and (mo > 2) then
- day = day + 1
- end
- return day
- end
- function SGP_Fraction_of_Day(hr,mi,se)
- return (hr + (mi + se/60)/60)/24
- end
- function SGP_isRepeated(s,catalog_num)
- local i = 1
- while i < s do
- if sgp_sats[i].catnr == catalog_num then
- --Actualizamos el satelite con los nuevos datos
- sgp_sats[i].catnr = sgp_sats[s].catnr
- sgp_sats[i].epoch = sgp_sats[s].epoch
- sgp_sats[i].julian_epoch = sgp_sats[s].julian_epoch
- sgp_sats[i].xndt2o = sgp_sats[s].xndt2o
- sgp_sats[i].xndd6o = sgp_sats[s].xndd6o
- sgp_sats[i].iexp = sgp_sats[s].iexp
- sgp_sats[i].bstar = sgp_sats[s].bstar
- sgp_sats[i].ibexp = sgp_sats[s].ibexp
- sgp_sats[i].elset = sgp_sats[s].elset
- sgp_sats[i].xincl = sgp_sats[s].xincl
- sgp_sats[i].xnodeo = sgp_sats[s].xnodeo
- sgp_sats[i].eo = sgp_sats[s].eo
- sgp_sats[i].omegao = sgp_sats[s].omegao
- sgp_sats[i].xmo = sgp_sats[s].xmo
- sgp_sats[i].xno = sgp_sats[s].xno
- sgp_sats[i].xndd6o = sgp_sats[s].xndd6o
- sgp_sats[i].bstar = sgp_sats[s].bstar
- sgp_sats[i].xnodeo = sgp_sats[s].xnodeo
- sgp_sats[i].omegao = sgp_sats[s].omegao
- sgp_sats[i].xmo = sgp_sats[s].xmo
- sgp_sats[i].xincl = sgp_sats[s].xincl
- sgp_sats[i].xno = sgp_sats[s].xno
- sgp_sats[i].xndt2o = sgp_sats[s].xndt2o
- sgp_sats[i].xndd6o = sgp_sats[s].xndd6o
- --Inicializa algunas variables
- sgp_sats[i].iflag = sgp_sats[s].iflag
- sgp_sats[i].primera_vez = sgp_sats[s].primera_vez
- sgp_sats[i].elevacion_ant = sgp_sats[s].elevacion_ant
- sgp_sats[i].no_calcular = sgp_sats[s].no_calcular
- return true
- else
- i = i + 1
- end
- end
- return false
- end
- function SGP_getLocationFromFile(filename)
- -- Miramos primero que el fichero exista
- local file = io.open(filename)
- if file then
- io.close(file)
- else
- return false
- end
- for line in io.lines(filename) do
- local str = string.sub(line,1,3)
- if str == "lat" then
- sgp_location.lat = tonumber(string.sub(line,5,string.len(line)))
- elseif str == "lon" then
- sgp_location.lon = tonumber(string.sub(line,5,string.len(line)))
- elseif str == "alt" then
- sgp_location.alt = tonumber(string.sub(line,5,string.len(line)))
- elseif str == "off" then
- sgp_location.UTC_offset = tonumber(string.sub(line,5,string.len(line)))
- elseif str == "nam" then
- sgp_location.name = string.sub(line,5,string.len(line))
- elseif str == "dst" then
- if ( string.sub(line,5,8) == "true" ) then
- sgp_location.dst = true
- else
- sgp_location.dst = false
- end
- end
- end
- sgp_location.polar.lat = math.rad(sgp_location.lat)
- sgp_location.polar.lon = math.rad(SGP_modulus(sgp_location.lon,360))
- sgp_location.polar.alt = sgp_location.alt * 0.001
- return true
- end
- function SGP_getStars(filename, mag)
- -- Miramos primero que el fichero exista
- local file = io.open(filename)
- if not file then
- return false
- end
- sgp_stars = {}
- sgp_stars2 = {}
- sgp_constellations = {}
- local i = 1
- local j = 1
- local sum_ra = 0
- local sum_dec = 0
- local line = file:read("*l")
- local primera_estrella = true
- while line do
- local str = string.sub(line,1,3)
- if tonumber(str) ~= nil then
- sgp_stars[i] = {}
- sgp_stars[i].id = tonumber(string.sub(line,1,4))
- sgp_stars[i].ra = tonumber(string.sub(line,6,13))*15
- sgp_stars[i].dec = tonumber(string.sub(line,15,23))
- sgp_stars[i].mag = tonumber(string.sub(line,25,29))
- sgp_stars[i].no_calcular = 0
- if sgp_stars[i].mag < mag then
- if primera_estrella then
- primera_estrella = false
- else
- local media = (sum_ra / (i - sgp_constellations[j-1].primero + 1))
- if math.abs(media - sgp_stars[i].ra) > 250 then
- if media > sgp_stars[i].ra then
- sgp_stars[i].ra = sgp_stars[i].ra + 360.0
- else
- sgp_stars[i].ra = sgp_stars[i].ra - 360.0
- end
- end
- end
- sum_ra = sum_ra + sgp_stars[i].ra
- sum_dec = sum_dec + sgp_stars[i].dec + 90.0
- i = i + 1
- end
- else
- if j > 1 then
- sgp_constellations[j-1].ultimo = i-1
- sgp_constellations[j-1].label_ra = (sum_ra / (sgp_constellations[j-1].ultimo - sgp_constellations[j-1].primero+1))
- sgp_constellations[j-1].label_dec = (sum_dec / (sgp_constellations[j-1].ultimo - sgp_constellations[j-1].primero+1)) - 90.0
- sum_ra = 0
- sum_dec = 0
- primera_estrella = true
- end
- sgp_constellations[j] = {}
- sgp_constellations[j].nombre = string.sub(line,1,string.len(line)-1)
- sgp_constellations[j].no_calcular = 0
- sgp_constellations[j].primero = i
- j = j + 1
- end
- line = file:read("*l")
- end
- file:close()
- sgp_star_number = i - 1
- sgp_constellation_number = j-1
- sgp_constellations[sgp_constellation_number].ultimo = sgp_star_number
- sgp_constellations[sgp_constellation_number].label_ra = sum_ra / (sgp_constellations[sgp_constellation_number].ultimo - sgp_constellations[sgp_constellation_number].primero + 1)
- sgp_constellations[sgp_constellation_number].label_dec = sum_dec / (sgp_constellations[sgp_constellation_number].ultimo - sgp_constellations[sgp_constellation_number].primero + 1)
- return true
- end
- function SGP_getTLE(filename)
- if sgp_sat_number < 0 then
- return
- end
- -- Miramos primero que el fichero exista
- local file = io.open(filename)
- if file then
- io.close(file)
- else
- sgp_sat_number = -2
- return
- end
- local sat_number = sgp_sat_number + 1
- local line_number = 1
- for line in io.lines(filename) do
- if line_number % 3 == 1 then
- -- Obtiene nombre y guarda los numeros de la estacion espacial y el shuttle
- --SL-16 R/B
- sgp_sats[sat_number] = { }
- sgp_sats[sat_number].numero = sat_number
- sgp_sats[sat_number].nombre = string.sub(line,1,24)
- elseif line_number % 3 == 2 then
- -- Obtiene primera linea
- --1 23405U 94077B 07216.52870987 -.00000029 00000-0 10000-4 0 7954
- if string.sub(line,1,2) == "1 " then
- if line:len() >= 69 then
- sgp_sats[sat_number].catnr = string.sub(line,3,7)
- sgp_sats[sat_number].epoch = tonumber(string.sub(line,19,32))
- sgp_sats[sat_number].julian_epoch = SGP_Julian_Date_of_Epoch(sgp_sats[sat_number].epoch)
- sgp_sats[sat_number].xndt2o = tonumber(string.sub(line,34,43))
- sgp_sats[sat_number].xndd6o = tonumber(string.sub(line,45,50)) * 0.00001
- sgp_sats[sat_number].iexp = tonumber(string.sub(line,51,52))
- sgp_sats[sat_number].bstar = tonumber(string.sub(line,54,59)) * 0.00001
- sgp_sats[sat_number].ibexp = tonumber(string.sub(line,60,61))
- sgp_sats[sat_number].elset = string.sub(line,66,69)
- else
- sgp_sat_number = -1
- return
- end
- else
- -- Suponer que se trata de la linea de nombre
- sgp_sats[sat_number] = { }
- sgp_sats[sat_number].numero = sat_number
- sgp_sats[sat_number].nombre = string.sub(line,1,24)
- line_number = line_number - 1
- end
- elseif line_number % 3 == 0 then
- -- Obtiene seguntda linea
- --2 23405 70.9690 232.0909 0004094 343.0355 17.0620 14.14891027655607
- if string.sub(line,1,2) == "2 " then
- if line:len() >= 69 then
- sgp_sats[sat_number].xincl = tonumber(string.sub(line,9,16))
- sgp_sats[sat_number].xnodeo = tonumber(string.sub(line,18,25))
- sgp_sats[sat_number].eo = tonumber(string.sub(line,27,33)) * 0.0000001
- sgp_sats[sat_number].omegao = tonumber(string.sub(line,35,40))
- sgp_sats[sat_number].xmo = tonumber(string.sub(line,44,51))
- sgp_sats[sat_number].xno = tonumber(string.sub(line,53,63))
- sgp_sats[sat_number].xndd6o = sgp_sats[sat_number].xndd6o * math.pow(10.0,sgp_sats[sat_number].iexp)
- sgp_sats[sat_number].bstar = (sgp_sats[sat_number].bstar * math.pow(10.0,sgp_sats[sat_number].ibexp)) / const_ae
- sgp_sats[sat_number].xnodeo = math.rad(sgp_sats[sat_number].xnodeo)
- sgp_sats[sat_number].omegao = math.rad(sgp_sats[sat_number].omegao)
- sgp_sats[sat_number].xmo = math.rad(sgp_sats[sat_number].xmo)
- sgp_sats[sat_number].xincl = math.rad(sgp_sats[sat_number].xincl)
- sgp_sats[sat_number].xno = (sgp_sats[sat_number].xno * (math.pi*2.0))/const_xmnpda
- sgp_sats[sat_number].xndt2o = (sgp_sats[sat_number].xndt2o * (math.pi*2.0))/const_xmnpda^2
- sgp_sats[sat_number].xndd6o = (sgp_sats[sat_number].xndd6o * (math.pi*2.0))/const_xmnpda^3
- --Inicializa algunas variables
- sgp_sats[sat_number].iflag = true
- sgp_sats[sat_number].primera_vez = true
- sgp_sats[sat_number].elevacion_ant = 0
- sgp_sats[sat_number].no_calcular = 0
- if not SGP_isRepeated(sat_number, sgp_sats[sat_number].catnr) then
- local cadena = string.sub(sgp_sats[sat_number].nombre,1,3)
- if cadena == "ISS" then
- sf_iss = sat_number
- sf_selected_sat = sf_iss
- end
- sat_number = sat_number + 1
- end
- else
- sgp_sat_number = -1
- return
- end
- else
- -- Suponer que se trata de la linea de nombre
- sgp_sats[sat_number] = { }
- sgp_sats[sat_number].numero = sat_number
- sgp_sats[sat_number].nombre = string.sub(line,1,24)
- line_number = line_number - 2
- end
- end
- line_number = line_number + 1
- end
- sgp_sat_number = sat_number - 1
- end
- function SGP_modulus( d1, d2)
- local modu
- modu = d1 - (math.floor(d1/d2) * d2)
- if modu >= 0 then
- return modu
- else
- return modu + d2
- end
- end
- function SGP_fmod2p( d )
- return SGP_modulus(d,(math.pi * 2.0))
- end
- function SGP_acTan(sinx,cosx)
- if cosx == 0 then
- if sinx > 0 then
- return (math.pi / 2.0)
- else
- return (3.0 * math.pi / 2.0)
- end
- else
- if cosx > 0 then
- return math.atan( sinx / cosx )
- else
- return math.pi + math.atan( sinx / cosx )
- end
- end
- end
- function SGP_deltaET (year)
- return (26.465 + 0.747622 * (year - 1950) + 1.886913 * math.sin((math.pi * 2.0) * (year - 1975.0) / 33.0))
- end
- function SGP_thetaG_JD( jd )
- local UT,TU,GMST
- UT = (jd + 0.5) - math.floor(jd + 0.5)
- jd = jd - UT
- TU = (jd - 2451545.0)/36525
- GMST = 24110.54841 + TU * (8640184.812866 + TU * (0.093104 - TU * 6.2 * 0.000001))
- GMST = SGP_modulus(GMST + const_secday * const_omega_E * UT,const_secday)
- return ((math.pi*2.0) * GMST/const_secday)
- end
- function SGP_magnitud( x,y,z )
- return math.sqrt(x^2 + y^2 + z^2)
- end
- function SGP_subVectores(v1, v2)
- local v3 = { }
- v3.x = v1.x - v2.x
- v3.y = v1.y - v2.y
- v3.z = v1.z - v2.z
- v3.m = SGP_magnitud(v3.x,v3.y,v3.z)
- return v3
- end
- -- Calcula el angulo comprendido entre los vectores v1 y v2
- function SGP_angulo(v1, v2)
- v1.m = SGP_magnitud(v1.x,v1.y,v1.z)
- v2.m = SGP_magnitud(v2.x,v2.y,v2.z)
- return math.acos(SGP_dot(v1,v2)/(v1.m * v2.m))
- end
- function SGP_dot(v1, v2)
- return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z
- end
- function SGP_calculateSatPosVel( sat , jtime )
- local i
- local cosuk,sinuk,rfdotk,vx,vy,vz,ux,uy,uz,xmy,xmx
- local cosnok,sinnok,cosik,sinik,rdotk,xinck,xnodek,uk,rk
- local cos2u,sin2u,u,sinu,cosu,betal,rfdot,rdot,r,pl,elsq
- local esine,ecose,epw,temp6,temp5,temp4,temp3,cosepw,sinepw
- local capu,ayn,xlt,aynl,xll,axn,xn,beta,xl,e,a,tfour,temp2
- local tcube,delm,delomg,templ,tempe,tempa,xnode,tsq,xmp,temp
- local omega,xnoddf,omgadf,xmdf,x,y,z,xdot,ydot,zdot,temp1
- local tsince = (jtime - sat.julian_epoch) * const_xmnpda
- -- Recover original mean motion (xnodp) and semimajor axis (aodp)
- -- from input elements.
- if sat.iflag then
- -- Initialization
- sat.a1 = math.pow(const_xke/sat.xno,const_tothrd)
- sat.cosio = math.cos(sat.xincl)
- sat.theta2 = sat.cosio^2
- sat.x3thm1 = (3.0 * sat.theta2) - 1.0
- sat.eosq = sat.eo^2
- sat.betao2 = 1.0 - sat.eosq
- sat.betao = math.sqrt(sat.betao2)
- sat.del1 = 1.5 * const_ck2 * sat.x3thm1 / (sat.a1 * sat.a1 * sat.betao * sat.betao2)
- sat.ao = sat.a1 * (1.0 - sat.del1 * (0.5 * const_tothrd + sat.del1 * (1.0 + 134.0 / 81.0 * sat.del1)))
- sat.delo = 1.5 * const_ck2 * sat.x3thm1 / (sat.ao * sat.ao * sat.betao * sat.betao2)
- sat.xnodp = sat.xno / (1.0 + sat.delo)
- sat.aodp = sat.ao / (1.0 - sat.delo)
- -- For perigee less than 220 kilometers, the isimp flag is set and
- -- the equations are truncated to linear variation in sqrt a and
- -- quadratic variation in mean anomaly. Also, the c3 term, the
- -- delta omega term, and the delta m term are dropped.
- sat.isimp = 0
- if ((sat.aodp*(1.0 - sat.eo)/const_ae) < (220.0/const_xkmper + const_ae)) then
- sat.isimp = 1
- end
- -- For perigee below 156 km, the values of s and qoms2t are altered.
- sat.s4 = const_s
- sat.qoms24 = const_qoms2t
- sat.perige = (sat.aodp * (1.0 - sat.eo) - const_ae)*const_xkmper
- if sat.perige < 156.0 then
- sat.s4 = sat.perige - 78.0
- if sat.perige <= 98.0 then
- sat.s4 = 20.0
- end
- sat.qoms24 = math.pow((120.0 - sat.s4) * const_ae / const_xkmper , 4.0)
- sat.s4 = sat.s4 / const_xkmper + const_ae
- end
- sat.pinvsq = 1.0 / (sat.aodp * sat.aodp * sat.betao2 * sat.betao2)
- sat.tsi = 1.0/(sat.aodp - sat.s4)
- sat.eta = sat.aodp * sat.eo * sat.tsi
- sat.etasq = sat.eta * sat.eta
- sat.eeta = sat.eo * sat.eta
- sat.psisq = math.abs(1.0 - sat.etasq)
- sat.coef = sat.qoms24 * math.pow(sat.tsi,4.0)
- sat.coef1 = sat.coef / math.pow(sat.psisq,3.5)
- sat.c2 = sat.coef1 * sat.xnodp * (sat.aodp * (1.0 + 1.5 * sat.etasq + sat.eeta * (4.0 + sat.etasq))
- + 0.75 * const_ck2 * sat.tsi/sat.psisq * sat.x3thm1 * (8.0 + 3.0 * sat.etasq * (8.0 + sat.etasq)))
- sat.c1 = sat.bstar * sat.c2
- sat.sinio = math.sin(sat.xincl)
- sat.a3ovk2 = (-const_xj3) / const_ck2 * math.pow(const_ae,3.0)
- sat.c3 = sat.coef * sat.tsi * sat.a3ovk2 * sat.xnodp * const_ae * sat.sinio / sat.eo
- sat.x1mth2 = 1.0 - sat.theta2
- sat.c4 = 2.0 * sat.xnodp * sat.coef1 * sat.aodp * sat.betao2 * (sat.eta * (2.0 + 0.5 * sat.etasq)
- + sat.eo * (0.5 + 2.0 * sat.etasq) - 2.0 * const_ck2 * sat.tsi/(sat.aodp * sat.psisq)
- * (-3.0 * sat.x3thm1 * (1.0 - 2.0 * sat.eeta + sat.etasq * (1.5 - 0.5 * sat.eeta))
- + 0.75 * sat.x1mth2 * (2.0 * sat.etasq - sat.eeta * (1.0 + sat.etasq)) * math.cos(2.0 * sat.omegao)))
- sat.c5 = 2.0 * sat.coef1 * sat.aodp * sat.betao2 * (1.0 + 2.75 * (sat.etasq + sat.eeta) + sat.eeta * sat.etasq)
- sat.theta4 = sat.theta2 * sat.theta2
- local temp1 = 3.0 * const_ck2 * sat.pinvsq * sat.xnodp
- local temp2 = temp1 * const_ck2 * sat.pinvsq
- local temp3 = 1.25 * const_ck4 * sat.pinvsq * sat.pinvsq * sat.xnodp
- sat.xmdot = sat.xnodp + 0.5 * temp1 * sat.betao * sat.x3thm1
- + 0.0625 * temp2 * sat.betao * (13.0 - 78.0 * sat.theta2 + 137.0 * sat.theta4)
- sat.x1m5th = 1.0 - 5.0 * sat.theta2
- sat.omgdot = -0.5 * temp1 * sat.x1m5th + 0.0625 * temp2 * (7.0 - 114.0 * sat.theta2 +395.0 * sat.theta4)
- + temp3 * (3.0 - 36.0 * sat.theta2 + 49.0 * sat.theta4)
- sat.xhdot1 = -temp1 * sat.cosio
- sat.xnodot = sat.xhdot1 + (0.5 * temp2 * (4.0 - 19.0 * sat.theta2)
- + 2.0 * temp3 * (3.0 - 7.0 * sat.theta2)) * sat.cosio
- sat.omgcof = sat.bstar * sat.c3 * math.cos(sat.omegao)
- sat.xmcof = -const_tothrd * sat.coef * sat.bstar * const_ae/sat.eeta
- sat.xnodcf = 3.5 * sat.betao2 * sat.xhdot1 * sat.c1
- sat.t2cof = 1.5 * sat.c1
- sat.xlcof = 0.125 * sat.a3ovk2 * sat.sinio * (3.0 + 5.0 * sat.cosio)/(1.0 + sat.cosio)
- sat.aycof = 0.25 * sat.a3ovk2 * sat.sinio
- sat.delmo = math.pow(1.0 + sat.eta * math.cos(sat.xmo),3.0)
- sat.sinmo = math.sin(sat.xmo)
- sat.x7thm1 = 7.0 * sat.theta2 - 1.0
- if sat.isimp ~= 1 then
- sat.c1sq = sat.c1 * sat.c1
- sat.d2 = 4.0 * sat.aodp * sat.tsi * sat.c1sq
- local temp = sat.d2 * sat.tsi * sat.c1/3.0
- sat.d3 = (17.0 * sat.aodp + sat.s4) * temp
- sat.d4 = 0.5 * temp * sat.aodp * sat.tsi * (221.0 * sat.aodp + 31.0 * sat.s4) * sat.c1
- sat.t3cof = sat.d2 + 2.0 * sat.c1sq
- sat.t4cof = 0.25 * (3.0 * sat.d3 + sat.c1 * (12.0 * sat.d2 + 10.0 * sat.c1sq))
- sat.t5cof = 0.2 * (3.0 * sat.d4 + 12.0 * sat.c1 * sat.d3 + 6.0 * sat.d2 * sat.d2 + 15.0 * sat.c1sq * (2.0 * sat.d2 + sat.c1sq))
- end
- sat.iflag = 0
- end
- --Update for secular gravity and atmospheric drag.
- xmdf = sat.xmo + sat.xmdot * tsince
- omgadf = sat.omegao + sat.omgdot * tsince
- xnoddf = sat.xnodeo + sat.xnodot * tsince
- omega = omgadf
- xmp = xmdf
- tsq = tsince * tsince
- xnode = xnoddf + sat.xnodcf * tsq
- tempa = 1.0 - sat.c1 * tsince
- tempe = sat.bstar * sat.c4 * tsince
- templ = sat.t2cof * tsq
- if not sat.isimp == 1 then
- delomg = sat.omgcof * tsince
- delm = sat.xmcof * (math.pow(1.0 + sat.eta * math.cos(xmdf),3.0) - sat.delmo)
- temp = delomg + delm
- xmp = xmdf + temp
- omega = omgadf - temp
- tcube = tsq * tsince
- tfour = tsince * tcube
- tempa = tempa - sat.d2 * tsq - sat.d3 * tcube - sat.d4 * tfour
- tempe = tempe + sat.bstar * sat.c5 * (math.sin(xmp) - sat.sinmo)
- templ = templ + sat.t3cof * tcube + tfour * (sat.t4cof + tsince * sat.t5cof)
- end
- a = sat.aodp * tempa * tempa
- e = sat.eo - tempe
- xl = xmp + omega + xnode + sat.xnodp * templ
- beta = math.sqrt(1.0 - e * e)
- xn = const_xke/math.pow(a,1.5)
- --Long period periodics
- axn = e * math.cos(omega)
- temp = 1.0/(a * beta * beta)
- xll = temp * sat.xlcof * axn
- aynl = temp * sat.aycof
- xlt = xl + xll
- ayn = e * math.sin(omega) + aynl
- -- Solve Kepler's Equation
- capu = SGP_fmod2p(xlt - xnode)
- i = 1
- epw = 0
- repeat
- i = i + 1
- if i == 2 then -- Primera iteración
- temp2 = capu
- else
- temp2 = epw
- end
- sinepw = math.sin(temp2)
- cosepw = math.cos(temp2)
- temp3 = axn * sinepw
- temp4 = ayn * cosepw
- temp5 = axn * cosepw
- temp6 = ayn * sinepw
- epw = (capu - temp4 + temp3 - temp2)/(1.0 - temp5 - temp6) + temp2
- until ((math.abs(epw - temp2) <= const_e6a) or (i>10))
- --Short period preliminary quantities
- ecose = temp5 + temp6
- esine = temp3 - temp4
- elsq = axn * axn + ayn * ayn
- temp = 1.0 - elsq
- pl = a * temp
- r = a * (1.0 - ecose)
- temp1 = 1.0/r
- rdot = const_xke * math.sqrt(a) * esine * temp1
- rfdot = const_xke * math.sqrt(pl) * temp1
- temp2 = a * temp1
- betal = math.sqrt(temp)
- temp3 = 1.0/(1.0 + betal)
- cosu = temp2 * (cosepw - axn + ayn * esine * temp3)
- sinu = temp2 * (sinepw - ayn - axn * esine * temp3)
- u = SGP_acTan(sinu,cosu)
- sin2u = 2.0 * sinu * cosu
- cos2u = 2.0 * cosu * cosu - 1.0
- temp = 1.0/pl
- temp1 = const_ck2 * temp
- temp2 = temp1 * temp
- --Update for short periodics
- rk = r * (1.0 - 1.5 * temp2 * betal * sat.x3thm1) + 0.5 * temp1 * sat.x1mth2 * cos2u
- uk = u - 0.25 * temp2 * sat.x7thm1 * sin2u
- xnodek = xnode + 1.5 * temp2 * sat.cosio * sin2u
- xinck = sat.xincl + 1.5 * temp2 * sat.cosio * sat.sinio * cos2u
- rdotk = rdot - xn * temp1 * sat.x1mth2 * sin2u
- rfdotk = rfdot + xn * temp1 * (sat.x1mth2 * cos2u + 1.5 * sat.x3thm1)
- --Orientation vectors
- sinuk = math.sin(uk)
- cosuk = math.cos(uk)
- sinik = math.sin(xinck)
- cosik = math.cos(xinck)
- sinnok = math.sin(xnodek)
- cosnok = math.cos(xnodek)
- xmx = -sinnok * cosik
- xmy = cosnok * cosik
- ux = xmx * sinuk + cosnok * cosuk
- uy = xmy * sinuk + sinnok * cosuk
- uz = sinik * sinuk
- vx = xmx * cosuk - cosnok * sinuk
- vy = xmy * cosuk - sinnok * sinuk
- vz = sinik * cosuk
- --Position and velocity
- x = rk * ux
- sat.x = x
- y = rk * uy
- sat.y = y
- z = rk * uz
- sat.z = z
- xdot = rdotk * ux + rfdotk * vx
- sat.vx = xdot
- ydot = rdotk * uy + rfdotk * vy
- sat.vy = ydot
- zdot = rdotk * uz + rfdotk * vz
- sat.vz = zdot
- --Convert sat state
- sat.x = sat.x * const_xkmper
- sat.vx = sat.vx * const_xkmper/60
- sat.y = sat.y * const_xkmper
- sat.vy = sat.vy * const_xkmper/60
- sat.z = sat.z * const_xkmper
- sat.vz = sat.vz * const_xkmper/60
- sat.m = math.sqrt(sat.x^2+sat.y^2+sat.z^2)
- sat.vm = math.sqrt(sat.vx^2+sat.vy^2+sat.vz^2)
- end
- function SGP_calculateSatIllum(sat)
- local sd_sun , sd_earth
- local delta
- local rho
- local earth
- -- Determina eclipse parcial
- sd_earth = math.asin(const_xkmper/sat.m)
- rho = SGP_subVectores(sgp_sun,sat)
- sd_sun = math.asin(const_sr/rho.m)
- earth = { }
- earth.x = -sat.x
- earth.y = -sat.y
- earth.z = -sat.z
- earth.m = sat.m
- delta = SGP_angulo(sgp_sun,earth)
- sat.depth = sd_earth - sd_sun - delta
- if sd_earth < sd_sun then
- sat.eclipsado = false
- else
- if sat.depth >= 0 then
- sat.eclipsado = true
- else
- sat.eclipsado = false
- end
- end
- end
- function SGP_calculateSatLatLonAlt (sat, jtime)
- local alt, lon, lat
- local theta, r, e2, phi, c
- theta = SGP_acTan(sat.y , sat.x)
- lon = SGP_modulus(theta - SGP_thetaG_JD(jtime),math.pi*2.0)
- r = math.sqrt(sat.x^2 + sat.y^2)
- e2 = const_f*(2.0 - const_f)
- lat = SGP_acTan(sat.z,r)
- repeat
- phi = lat
- c = 1.0/math.sqrt(1.0 - e2* math.pow(math.sin(phi),2.0))
- lat = SGP_acTan(sat.z + const_xkmper * c * e2 * math.sin(phi),r)
- until (math.abs(lat-phi) < 0.0000000001)
- alt = r/math.cos(lat) - const_xkmper * c
- sat.latitud = math.deg(lat)
- sat.longitud = math.deg(lon)
- sat.altitud = alt
- if (sat.longitud >= 180) then
- sat.longitud = sat.longitud - 360
- end
- end
- function SGP_calculateSun (jtime)
- SGP_calculateSunPosition( jtime )
- SGP_calculateLocation( jtime )
- SGP_calculateSunAzElev( jtime )
- end
- function SGP_calculateSunPosition(jtime)
- local mjd,year,T,M,L,e,C,O,Lsa,nu,R,eps
- local alt, lon, lat
- local thetaAux, r, e2, phi, c2
- mjd = jtime - 2415020.0
- year = 1900.0 + mjd/365.25
- T = (mjd + SGP_deltaET(year)/const_secday)/36525.0
- M = math.rad(SGP_modulus(358.47583 + SGP_modulus(35999.04975 * T,360.0) - (0.000150 + 0.0000033*T)*(T*T),360.0))
- L = math.rad(SGP_modulus(279.69668 + SGP_modulus(36000.76892*T,360.0) + 0.0003025*(T*T),360.0))
- e = 0.01675104 - (0.0000418 + 0.000000126*T)*T
- C = math.rad((1.919460 - (0.004789 + 0.000014*T)*T)*math.sin(M) + (0.020094 - 0.000100*T)*math.sin(2.0*M) + 0.000293*math.sin(3.0*M))
- O = math.rad(SGP_modulus(259.18 - 1934.142*T,360.0))
- Lsa = SGP_modulus(L + C - math.rad(0.00569 - 0.00479*math.sin(O)),(math.pi*2.0))
- nu = SGP_modulus(M + C,(math.pi*2.0))
- R = 1.0000002*(1.0 - (e*e))/(1.0 + e*math.cos(nu))
- eps = math.rad(23.452294 - (0.0130125 + (0.00000164 - 0.000000503*T)*T)*T + 0.00256*math.cos(O))
- R = const_AU*R
- sgp_sun.x = R*math.cos(Lsa)
- sgp_sun.y = R*math.sin(Lsa)*math.cos(eps)
- sgp_sun.z = R*math.sin(Lsa)*math.sin(eps)
- sgp_sun.m = R
- thetaAux = SGP_acTan(sgp_sun.y,sgp_sun.x)
- lon = SGP_modulus(thetaAux - SGP_thetaG_JD(jtime),math.pi*2.0)
- r = math.sqrt(sgp_sun.x^2 + sgp_sun.y^2)
- e2 = const_f*(2.0 - const_f)
- lat = SGP_acTan(sgp_sun.z,r)
- repeat
- phi = lat
- c2 = 1.0 / math.sqrt (1.0 - e2 * math.pow(math.sin(phi),2.0))
- lat = SGP_acTan(sgp_sun.z + const_xkmper*c2*e2*math.sin(phi),r)
- until (math.abs(lat-phi) < 0.0000000001)
- alt = (r / math.cos(lat)) - (const_xkmper * c2)
- sgp_sun.lat = math.deg(lat)
- sgp_sun.lon = math.deg(lon)
- sgp_sun.alt = alt
- theta = thetaAux
- if sgp_sun.lon >= 180 then
- sgp_sun.lon = sgp_sun.lon - 360
- end
- end
- function SGP_calculateSunAzElev( jt )
- local i
- local sin_lat,cos_lat, sin_theta,cos_theta
- local el,azim,lat,theta
- local top_s,top_e,top_z
- --antiguamente llamado calcular variables
- local range = {}
- local rgvel = {}
- range.x = sgp_sun.x - sgp_location.x
- rgvel.x = 0.0 - sgp_location.vx
- range.y = sgp_sun.y - sgp_location.y
- rgvel.y = 0.0 - sgp_location.vy
- range.z = sgp_sun.z - sgp_location.z
- rgvel.z = 0.0 - sgp_location.vz
- range.m = SGP_magnitud(range.x,range.y,range.z)
- lat = sgp_location.polar.lat
- theta = sgp_location.polar.m
- sin_lat = math.sin(lat)
- cos_lat = math.cos(lat)
- sin_theta = math.sin(theta)
- cos_theta = math.cos(theta)
- top_s = sin_lat * cos_theta * range.x + sin_lat * sin_theta * range.y - cos_lat * range.z
- top_e = -sin_theta * range.x + cos_theta * range.y
- top_z = cos_lat * cos_theta * range.x + cos_lat * sin_theta * range.y + sin_lat * range.z
- azim = math.atan(-top_e/top_s) --Azimuth
- if (top_s > 0) then
- azim = azim + math.pi
- end
- if (azim < 0) then
- azim = azim + (math.pi * 2.0)
- end
- el = math.asin(top_z/range.m)
- sgp_sun.azi = math.deg(azim) --Azimuth (radians to degrees)
- --sgp_sol.elevacion = el --Elevation (radians)
- sgp_sun.rango = range.m --Range (kilometers)
- sgp_sun.ratioRango = SGP_dot(range,rgvel)/range.m --Range Rate (kilometers/second)
- -- Corrections for atmospheric refraction }
- -- Reference: Astronomical Algorithms by Jean Meeus, pp. 101-104 }
- -- Note: Correction is meaningless when apparent elevation is below horizon }
- sgp_sun.ele = el + math.rad((1.02/math.tan(math.rad(math.deg(el)+10.3/(math.deg(el)+5.11))))/60.0)
- --if (sgp_sun.ele < -3) then
- -- sgp_sun.ele = el --reset to true elevation
- --end
- sgp_sun.ele = math.deg(sgp_sun.ele)
- sgp_location.noche = (sgp_sun.ele < const_twilightCivil)
- end
- function SGP_calculateSatAzElev (sat, jt)
- local i
- local sin_lat,cos_lat, sin_theta,cos_theta
- local el,azim,lat,theta
- local top_s,top_e,top_z
- SGP_calculateLocation(jt);
- local range = {}
- local rgvel = {}
- range.x = sat.x - sgp_location.x
- range.y = sat.y - sgp_location.y
- range.z = sat.z - sgp_location.z
- rgvel.x = sat.vx - sgp_location.vx
- rgvel.y = sat.vy - sgp_location.vy
- rgvel.z = sat.vz - sgp_location.vz
- range.m = SGP_magnitud(range.x,range.y,range.z)
- lat = sgp_location.polar.lat
- theta = sgp_location.polar.m
- sin_lat = math.sin(lat)
- cos_lat = math.cos(lat)
- sin_theta = math.sin(theta)
- cos_theta = math.cos(theta)
- top_s = sin_lat*cos_theta*range.x + sin_lat*sin_theta*range.y - cos_lat*range.z
- top_e = -sin_theta*range.x + cos_theta*range.y
- top_z = cos_lat*cos_theta*range.x + cos_lat*sin_theta*range.y + sin_lat*range.z
- azim = math.atan(-top_e/top_s) --Azimuth
- if (top_s > 0) then
- azim = azim + math.pi
- end
- if (azim < 0) then
- azim = azim + (math.pi*2.0)
- end
- el = math.asin(top_z/range.m)
- sat.azimut = math.deg(azim) --Azimuth (radians to degrees)
- --sat.elevacion = el --Elevation (radians)
- sat.rango = range.m --Range (kilometers)
- sat.ratioRango = SGP_dot(range,rgvel)/range.m --Range Rate (kilometers/second)
- -- Corrections for atmospheric refraction }
- -- Reference: Astronomical Algorithms by Jean Meeus, pp. 101-104 }
- -- Note: Correction is meaningless when apparent elevation is below horizon }
- if not sat.primera_vez then
- sat.elevacion_ant = sat.elevacion
- else
- sat.primera_vez = false
- end
- sat.elevacion = el + math.rad((1.02/math.tan(math.rad(math.deg(el)+10.3/(math.deg(el)+5.11))))/60.0)
- if (sat.elevacion < 0) then
- sat.elevacion = el --Reset to true elevation
- end
- sat.elevacion = math.deg(sat.elevacion)
- end
- function SGP_calculateSatVisibility(sat)
- sat.visible = ( (not sat.eclipsado) and (sgp_location.noche) and (sat.elevacion > 0))
- end
- function SGP_calculateLocation(jt)
- local c,s,achcp
- local lat, lon, alt, theta
- lat = sgp_location.polar.lat
- lon = sgp_location.polar.lon
- alt = sgp_location.polar.alt
- --LMST
- theta = SGP_modulus(SGP_thetaG_JD(jt) + lon,(math.pi * 2))
- sgp_location.polar.m=theta
- c = 1.0/math.sqrt(1.0 + const_f*(const_f - 2.0)*math.pow(math.sin(lat),2.0))
- s = ((1 - const_f)*(1 - const_f))*c
- achcp = (const_xkmper*c + alt)*math.cos(lat)
- sgp_location.x = achcp*math.cos(theta) -- kilometros
- sgp_location.y = achcp*math.sin(theta)
- sgp_location.z = (const_xkmper*s + alt)*math.sin(lat)
- sgp_location.vx = -const_mfactor*sgp_location.y --kilometers/second
- sgp_location.vy = const_mfactor*sgp_location.x
- sgp_location.vz = 0
- sgp_location.m = SGP_magnitud(sgp_location.x,sgp_location.y,sgp_location.z)
- sgp_location.vm = SGP_magnitud(sgp_location.vx,sgp_location.vy,sgp_location.vz)
- end
- function SGP_calculateSatellite (s , jtime)
- SGP_calculateSatPosVel (sgp_sats[s], jtime)
- SGP_calculateSatIllum(sgp_sats[s])
- SGP_calculateSatLatLonAlt (sgp_sats[s], jtime)
- SGP_calculateSatAzElev (sgp_sats[s], jtime)
- SGP_calculateSatVisibility(sgp_sats[s])
- end
- function SGP_fixangle(a)
- return ((a) - 360.0 * (math.floor((a) / 360.0)))
- end
- -- KEPLER -- Solve the equation of Kepler.
- function SGP_kepler( m, ecc)
- local e, delta
- local EPSILON = 0.000001
- m = SGP_dtr(m)
- e = m
- repeat
- delta = e - ecc * math.sin(e) - m
- e = e - delta / (1 - ecc * math.cos(e))
- until not (math.abs(delta) > EPSILON)
- return e
- end
- function SGP_fixangr(a)
- return ((a) - (math.pi*2) * (math.floor((a) / (math.pi*2))))
- end
- function SGP_dtr(x)
- return ((x) * (math.pi / 180.0))
- end
- function SGP_rtd(x)
- return ((x) / (math.pi / 180.0))
- end
- function SGP_highmoon(jd)
- local t, t2, t3, t4, lprime, d, m, mprime, f, a1, a2, a3
- local e = {}
- local sigmaL, sigmaB, sigmaR, ang
- local i
- local l, b, r
- t = (jd - const_J2000) / const_JulianCentury
- t2 = t * t
- t3 = t * t2
- t4 = t * t3
- lprime = 218.3164591 + 481267.88134236 * t - 0.0013268 * t2 +
- t3 / 538841.0 - t4 / 65194000.0
- d = 297.8502042 + 445267.1115168 * t - 0.00163 * t2 +
- t3 / 545868.0 - t4 / 113065000.0
- m = 357.5291092 + 35999.0502909 * t - 0.0001536 * t2 +
- t3 / 24490000.0
- mprime = 134.9634114 + 477198.8676313 * t + 0.008997 * t2 +
- t3 / 69699.0 - t4 / 14712000.0
- f = 93.2720993 + 483202.0175273 * t - 0.0034029 * t2 -
- t3 / 3526000.0 + t4 / 863310000.0
- a1 = 119.75 + 131.849 * t
- a2 = 53.09 + 479264.29 * t
- a3 = 313.45 + 481266.484 * t
- e[1] = 1
- e[2] = 1 - (0.002516 * t) - (0.0000074 * t2)
- e[3] = e[2] * e[2]
- lprime = SGP_fixangr(SGP_dtr(lprime))
- d = SGP_fixangr(SGP_dtr(d))
- m = SGP_fixangr(SGP_dtr(m))
- mprime = SGP_fixangr(SGP_dtr(mprime))
- f = SGP_fixangr(SGP_dtr(f))
- a1 = SGP_fixangr(SGP_dtr(a1))
- a2 = SGP_fixangr(SGP_dtr(a2))
- a3 = SGP_fixangr(SGP_dtr(a3))
- sigmaR = 0
- sigmaB = 0
- sigmaL = 0
- for i = 1,const_NTERMS do
- ang = sgp_lrCoeff[i][1] * d + sgp_lrCoeff[i][2] * m +
- sgp_lrCoeff[i][3] * mprime + sgp_lrCoeff[i][4] * f
- sigmaL = sigmaL + sgp_lTerms[i] * math.sin(ang) * e[math.abs(sgp_lrCoeff[i][2])+1]
- if (sgp_rTerms[i] ~= 0) then
- sigmaR = sigmaR + sgp_rTerms[i] * math.cos(ang) * e[math.abs(sgp_lrCoeff[i][2])+1]
- end
- ang = sgp_bCoeff[i][1] * d + sgp_bCoeff[i][2] * m +
- sgp_bCoeff[i][3] * mprime + sgp_bCoeff[i][4] * f
- sigmaB = sigmaB + sgp_bTerms[i] * math.sin(ang) * e[math.abs(sgp_bCoeff[i][2])+1]
- end
- sigmaL = sigmaL + 3958.0 * math.sin(a1) + 1962.0 * math.sin(lprime - f) + 318.0 * math.sin(a2)
- sigmaB = sigmaB - 2235.0 * math.sin(lprime) + 382.0 * math.sin(a3) + 175.0 * math.sin(a1 - f) +
- 175.0 * math.sin(a1 + f) + 127.0 * math.sin(lprime - mprime) - 115.0 * math.sin(lprime + mprime)
- l = SGP_rtd(lprime) + sigmaL / 1000000.0
- b = sigmaB / 1000000.0
- r = 385000.56 + sigmaR / 1000.0
- return l, b, r
- end
- function SGP_Asec(x)
- return ((x) / 3600.0)
- end
- -- OBLIQEQ -- Calculate the obliquity of the ecliptic for a given Julian
- --date. This uses Laskar's tenth-degree polynomial fit
- --(J. Laskar, Astronomy and Astrophysics, Vol. 157, page 68 [1986])
- --which is accurate to within 0.01 arc second between AD 1000
- --and AD 3000, and within a few seconds of arc for +/-10000
- --years around AD 2000. If we're outside the range in which
- --this fit is valid (deep time) we simply return the J2000 value
- -- the obliquity, which happens to be almost precisely the mean. */
- function SGP_obliqeq( jd )
- local oterms = {SGP_Asec(-4680.93),
- SGP_Asec( -1.55),
- SGP_Asec( 1999.25),
- SGP_Asec( -51.38),
- SGP_Asec( -249.67),
- SGP_Asec( -39.05),
- SGP_Asec( 7.12),
- SGP_Asec( 27.87),
- SGP_Asec( 5.79),
- SGP_Asec( 2.45)}
- local eps, i, u, v
- eps = 23 + (26 / 60.0) + (21.448 / 3600.0)
- u = (jd - const_J2000) / (const_JulianCentury * 100)
- v = u
- if (math.abs(u) < 1.0) then
- for i = 1, 10 do
- eps = eps + oterms[i] * v
- v = v * u
- end
- end
- return eps
- end
- -- ECLIPTOEQ -- Convert celestial (ecliptical) longitude and latitude into
- --right ascension (in degrees) and declination. We must supply
- --the time of the conversion in order to compensate correctly
- --for the varying obliquity of the ecliptic over time. */
- function SGP_ecliptoeq(jd,Lambda, Beta)
- local eps
- local Ra, Dec
- -- Obliquity of the ecliptic.
- eps = SGP_dtr(SGP_obliqeq(jd))
- Ra = SGP_fixangle(SGP_rtd(math.atan2((math.cos(eps) * math.sin(SGP_dtr(Lambda)) -
- (math.tan(SGP_dtr(Beta)) * math.sin(eps))), math.cos(SGP_dtr(Lambda)))))
- Dec = SGP_rtd(math.asin((math.sin(eps) * math.sin(SGP_dtr(Lambda)) * math.cos(SGP_dtr(Beta))) +
- (math.sin(SGP_dtr(Beta)) * math.cos(eps))))
- return Ra, Dec
- end
- function SGP_RADecToAzElev (jd, ra, dec, lat, lon)
- local r = math.rad(ra)
- local d = math.rad(dec)
- local n = math.rad(lat) -- North latitude of tracking station
- local e = -math.rad(lon) -- East longitude of tracking station
- -- Find siderial time in radians
- local t=(jd-2451545.0)/36525.0
- local teg=280.46061837+360.98564736629*(jd-2451545.0)+(0.000387933*t-t*t/38710000.0)*t
- while (teg>360.0) do
- teg = teg - 360.0
- end
- th = math.rad(teg - lon)
- while (th > 2*math.pi) do
- th = th - 2*math.pi
- end
- local h=th-r
- az=math.atan2(math.sin(h),math.cos(h)*math.sin(n)-math.tan(d)*math.cos(n))+math.pi
- el=math.asin(math.sin(n)*math.sin(d)+math.cos(n)*math.cos(d)*math.cos(h))
- local el_with_atmosphere_refraction = el + math.rad((1.02/math.tan(math.rad(math.deg(el)+10.3/(math.deg(el)+5.11))))/60.0)
- if (el_with_atmosphere_refraction < 0) then
- el_with_atmosphere_refraction = el --reset to true elevation
- end
- return math.deg(az), math.deg(el_with_atmosphere_refraction)
- end
- -- GMST -- Calculate Greenwich Mean Siderial Time for a given instant expressed as a Julian date and fraction.
- function SGP_gmst(jd)
- local t, theta0
- -- Time, in Julian centuries of 36525 ephemeris days, measured from the epoch 1900 January 0.5 ET.
- t = ((math.floor(jd + 0.5) - 0.5) - 2415020.0) / const_JulianCentury
- theta0 = 6.6460656 + 2400.051262 * t + 0.00002581 * t * t
- t = (jd + 0.5) - (math.floor(jd + 0.5))
- theta0 = theta0 + (t * 24.0) * 1.002737908
- theta0 = (theta0 - 24.0 * (math.floor(theta0 / 24.0)))
- return theta0
- end
- function SGP_calculateMoon(jt)
- local Day, N, M, Ec, Lambdasun, ml, MM, MN, Ev, Ae, A3, MmP
- local mEc, A4, lP, Varia, lPP, NP, magnitud, z, y, x, Lambdamoon
- local MoonAge, MoonPhase, MoonDist, MoonDFrac, MoonAng
- local F, SunDist, SunAng
- -- Calculation of the Sun's position
- Day = jt - const_epoch --Date within epoch
- N = SGP_fixangle((360 / 365.2422) * Day) -- Mean anomaly of the Sun
- M = SGP_fixangle(N + const_elonge - const_elongp) --Convert from perigee co-ordinates to epoch 1980.0
- Ec = SGP_kepler(M, const_eccent) -- Solve equation of Kepler
- Ec = math.sqrt((1 + const_eccent) / (1 - const_eccent)) * math.tan(Ec / 2)
- Ec = 2 * SGP_rtd(math.atan(Ec)) -- True anomaly
- Lambdasun = SGP_fixangle(Ec + const_elongp) -- Sun's geocentric ecliptic longitude
- -- Orbital distance factor
- F = ((1 + const_eccent * math.cos(SGP_dtr(Ec))) / (1 - const_eccent * const_eccent))
- SunDist = const_SunSMAX / F -- Distance to Sun in km
- SunAng = F * const_sunangsiz --Sun's angular size in degrees */
- -- Calculation of the Moon's position
- -- Moon's mean longitude
- ml = SGP_fixangle(13.1763966 * Day + const_mmlong)
- -- Moon's mean anomaly
- MM = SGP_fixangle(ml - 0.1114041 * Day - const_mmlongp)
- -- Moon's ascending node mean longitude
- MN = SGP_fixangle(const_mlnode - 0.0529539 * Day)
- -- Evection
- Ev = 1.2739 * math.sin(SGP_dtr(2 * (ml - Lambdasun) - MM))
- -- Annual equation
- Ae = 0.1858 * math.sin(SGP_dtr(M))
- -- Correction term
- A3 = 0.37 * math.sin(SGP_dtr(M))
- -- Corrected anomaly
- MmP = MM + Ev - Ae - A3
- -- Correction for the equation of the centre
- mEc = 6.2886 * math.sin(SGP_dtr(MmP))
- -- Another correction term
- A4 = 0.214 * math.sin(SGP_dtr(2 * MmP))
- -- Corrected longitude
- lP = ml + Ev + mEc - Ae + A4
- -- Variation
- Varia = 0.6583 * math.sin(SGP_dtr(2 * (lP - Lambdasun)))
- -- True longitude
- lPP = lP + Varia
- -- Corrected longitude of the node
- NP = MN - 0.16 * math.sin(SGP_dtr(M))
- -- Y inclination coordinate
- y = math.sin(SGP_dtr(lPP - NP)) * math.cos(SGP_dtr(const_minc))
- -- X inclination coordinate
- x = math.cos(SGP_dtr(lPP - NP))
- -- Ecliptic longitude
- Lambdamoon = SGP_rtd(math.atan2(y, x))
- Lambdamoon = Lambdamoon + NP
- -- Ecliptic latitude
- -- BetaM = rtd(asin(sin(dtr(lPP - NP)) * sin(dtr(minc))));
- -- Calculation of the phase of the Moon
- -- Age of the Moon in degrees
- MoonAge = lPP - Lambdasun
- -- Phase of the Moon
- MoonPhase = (1 - math.cos(SGP_dtr(MoonAge))) / 2
- -- Calculate distance of moon from the centre of the Earth
- MoonDist = (const_msmax * (1 - const_mecc * const_mecc)) / (1 + const_mecc * math.cos(SGP_dtr(MmP + mEc)))
- -- Calculate Moon's angular diameter
- MoonDFrac = MoonDist / const_msmax
- MoonAng = const_mangsiz / MoonDFrac
- -- Calculate Moon's parallax
- -- MoonPar = mparallax / MoonDFrac;
- SGP_calculateLocation(jt)
- local igmst = SGP_gmst(jt)
- local moonlong, moonlat, mooncrv = SGP_highmoon( jt )
- local moonra, moondec = SGP_ecliptoeq(jt, moonlong, moonlat)
- moonlong = (igmst * 15) - moonra;
- moonlong = -moonlong
- if (moonlong > 180) then
- moonlong = moonlong - 360
- elseif (moonlong < -180) then
- moonlong = moonlong + 360
- end
- local moonaz, moonele = SGP_RADecToAzElev(jt, moonra, moondec,sgp_location.lat, sgp_location.lon)
- sgp_moon.ra = moonra
- sgp_moon.dec = moondec
- sgp_moon.lon = moonlong
- sgp_moon.lat = moonlat
- sgp_moon.azi = moonaz
- sgp_moon.ele = moonele + (1.02/math.tan(math.rad(moonele+10.3/(moonele+5.11))))/60.0
- sgp_moon.phase = MoonPhase
- local aom = const_SynMonth * (SGP_fixangle(MoonAge) / 360.0)
- sgp_moon.age.cicle = aom / const_SynMonth
- sgp_moon.age.d = math.floor(aom)
- sgp_moon.age.h = math.floor(24 * (aom - math.floor(aom)))
- sgp_moon.age.m = math.floor((1440 * (aom - math.floor(aom))) % 60)
- sgp_moon.dist = MoonDist
- sgp_moon.ang = MoonAng
- sgp_moon.sun_dist = SunDist
- sgp_moon.sun_ang = SunAng
- end
- function SGP_calculateSunRaiseTime()
- SGP_getCurrentTime()
- local jtime = sgp_time.ujtime
- SGP_calculateSun (jtime)
- if sgp_sun.ele > 0 then
- repeat
- jtime = jtime - 0.000694446 * 10
- SGP_calculateSun (jtime)
- until (sgp_sun.ele < 0)
- repeat
- jtime = jtime + 0.000694446
- SGP_calculateSun (jtime)
- until (sgp_sun.ele > 0)
- repeat
- jtime = jtime - 0.000694446 * 0.16
- SGP_calculateSun (jtime)
- until (sgp_sun.ele <= 0)
- else
- repeat
- jtime = jtime + 0.000694446 * 10
- SGP_calculateSun (jtime)
- until (sgp_sun.ele > 0)
- repeat
- jtime = jtime - 0.000694446
- SGP_calculateSun (jtime)
- until (sgp_sun.ele < 0)
- repeat
- jtime = jtime + 0.000694446 * 0.16
- SGP_calculateSun (jtime)
- until (sgp_sun.ele >= 0)
- end
- SGP_calculateSun (sgp_time.ujtime)
- sgp_sun.raise.jt = SGP_UTC_to_Local(jtime)
- sgp_sun.raise.year , sgp_sun.raise.month, sgp_sun.raise.day, sgp_sun.raise.hour, sgp_sun.raise.min, sgp_sun.raise.sec = SGP_Julian_To_Date(sgp_sun.raise.jt)
- end
- function SGP_calculateMoonRaiseTime()
- SGP_getCurrentTime()
- local jtime = sgp_time.ujtime
- SGP_calculateMoon (jtime)
- if sgp_moon.ele > 0 then
- repeat
- jtime = jtime - 0.000694446 * 10
- SGP_calculateMoon (jtime)
- until (sgp_moon.ele < 0)
- repeat
- jtime = jtime + 0.000694446
- SGP_calculateMoon (jtime)
- until (sgp_moon.ele > 0)
- repeat
- jtime = jtime - 0.000694446 * 0.16
- SGP_calculateMoon (jtime)
- until (sgp_moon.ele <= 0)
- else
- repeat
- jtime = jtime + 0.000694446 * 10
- SGP_calculateMoon (jtime)
- until (sgp_moon.ele > 0)
- repeat
- jtime = jtime - 0.000694446
- SGP_calculateMoon (jtime)
- until (sgp_moon.ele < 0)
- repeat
- jtime = jtime + 0.000694446 * 0.16
- SGP_calculateMoon (jtime)
- until (sgp_moon.ele >= 0)
- end
- SGP_calculateMoon (sgp_time.ujtime)
- sgp_moon.raise.jt = SGP_UTC_to_Local(jtime)
- sgp_moon.raise.year , sgp_moon.raise.month, sgp_moon.raise.day, sgp_moon.raise.hour, sgp_moon.raise.min, sgp_moon.raise.sec = SGP_Julian_To_Date(sgp_moon.raise.jt)
- end
- function SGP_calculateSunSetTime()
- SGP_getCurrentTime()
- local jtime = sgp_time.ujtime
- SGP_calculateSun (jtime)
- if sgp_sun.ele < 0 then
- repeat
- jtime = jtime - 0.000694446 * 10
- SGP_calculateSun (jtime)
- until (sgp_sun.ele > 0)
- repeat
- jtime = jtime + 0.000694446
- SGP_calculateSun (jtime)
- until (sgp_sun.ele < 0)
- repeat
- jtime = jtime - 0.000694446 * 0.16
- SGP_calculateSun (jtime)
- until (sgp_sun.ele >= 0)
- else
- repeat
- jtime = jtime + 0.000694446 * 10
- SGP_calculateSun (jtime)
- until (sgp_sun.ele < 0)
- repeat
- jtime = jtime - 0.000694446
- SGP_calculateSun (jtime)
- until (sgp_sun.ele > 0)
- repeat
- jtime = jtime + 0.000694446 * 0.16
- SGP_calculateSun (jtime)
- until (sgp_sun.ele <= 0)
- end
- SGP_calculateSun (sgp_time.ujtime)
- sgp_sun.set.jt = SGP_UTC_to_Local(jtime)
- sgp_sun.set.year , sgp_sun.set.month, sgp_sun.set.day, sgp_sun.set.hour, sgp_sun.set.min, sgp_sun.set.sec = SGP_Julian_To_Date(sgp_sun.set.jt)
- end
- function SGP_calculateMoonSetTime()
- SGP_getCurrentTime()
- local jtime = sgp_time.ujtime
- SGP_calculateMoon (jtime)
- if sgp_moon.ele < 0 then
- repeat
- jtime = jtime - 0.000694446 * 10
- SGP_calculateMoon (jtime)
- until (sgp_moon.ele > 0)
- repeat
- jtime = jtime + 0.000694446
- SGP_calculateMoon (jtime)
- until (sgp_moon.ele < 0)
- repeat
- jtime = jtime - 0.000694446 * 0.16
- SGP_calculateMoon (jtime)
- until (sgp_moon.ele >= 0)
- else
- repeat
- jtime = jtime + 0.000694446 * 10
- SGP_calculateMoon (jtime)
- until (sgp_moon.ele < 0)
- repeat
- jtime = jtime - 0.000694446
- SGP_calculateMoon (jtime)
- until (sgp_moon.ele > 0)
- repeat
- jtime = jtime + 0.000694446 * 0.16
- SGP_calculateMoon (jtime)
- until (sgp_moon.ele <= 0)
- end
- SGP_calculateMoon (sgp_time.ujtime)
- sgp_moon.set.jt = SGP_UTC_to_Local(jtime)
- sgp_moon.set.year , sgp_moon.set.month, sgp_moon.set.day, sgp_moon.set.hour, sgp_moon.set.min, sgp_moon.set.sec = SGP_Julian_To_Date(sgp_moon.set.jt)
- end
- function SGP_calculateMoonPhases ()
- SGP_getCurrentTime();
- local day = sgp_time.day
- local mon = sgp_time.month
- local year = sgp_time.year
- local s
- local k, T, T2, T3, RAD, M, M1, F, AJ, BJ, CJ
- local JD
- for s=0,3 do
- k=math.floor((year+((mon+(day/30.0)-1.0)/12.0)-1900.0)*12.3685+0.5)
- k=k+0.25*s
- T=(k/1236.85)
- T2=T*T
- T3=T2*T
- RAD=57.29577951
- -- Tiempo para las fases medias
- JD=2415020.75933+29.53058868*k+0.0001178*T2-0.000000155*T3+0.00033*math.sin((166.56+132.87*T-0.009173*T2)/RAD)
- -- Anomalias mediasde Sol y Luna y arg. latitud
- M=359.2242+29.10535608*k-0.0000333*T2-0.00000347*T3
- M1=306.0253+385.81691806*k+0.0107306*T2+0.00001236*T3
- F=21.2964+390.67050646*k-0.0016528*T2-0.00000239*T3
- M=M/RAD
- M1=M1/RAD
- F=F/RAD
- -- Correción para Luna Nueva y Llena
- AJ=(0.1734-0.000393*T)*math.sin(M)+0.0021*math.sin(2*M)-0.4068*math.sin(M1)+0.0161*math.sin(2*M1)
- AJ=AJ-0.0004*math.sin(3*M1)+0.0104*math.sin(2*F)-0.0051*math.sin(M+M1)-0.0074*math.sin(M-M1)
- AJ=AJ+0.0004*math.sin(2*F+M)-0.0004*math.sin(2*F-M)-0.0006*math.sin(2*F+M1)+0.0010*math.sin(2*F-M1)
- AJ=AJ+0.0005*math.sin(M+2*M1)
- -- Correción para Cuarto creciente y menguante
- BJ=(0.1721-0.0004*T)*math.sin(M)+0.0021*math.sin(2*M)-0.6280*math.sin(M1)+0.0089*math.sin(2*M1)
- BJ=BJ-0.0004*math.sin(3*M1)+0.0079*math.sin(2*F)-0.0119*math.sin(M+M1)-0.0047*math.sin(M-M1)
- BJ=BJ+0.0003*math.sin(2*F+M)-0.0004*math.sin(2*F-M)-0.0006*math.sin(2*F+M1)+0.0021*math.sin(2*F-M1)
- BJ=BJ+0.0003*math.sin(M+2*M1)+0.0004*math.sin(M-2*M1)-0.0003*math.sin(2*M+M1)
- CJ=0.0028-0.0004*math.cos(M)+0.0003*math.cos(M1)
- if s==0 then
- sgp_moon.new_moon=JD+AJ
- end
- if s==1 then
- sgp_moon.first_quarter_moon=JD+BJ+CJ
- end
- if s==2 then
- sgp_moon.full_moon=JD+AJ
- end
- if s==3 then
- sgp_moon.third_quarter_moon=JD+BJ-CJ
- end
- end
- end
- function SGP_calculateNightEnding()
- SGP_getCurrentTime()
- local jtime = sgp_time.ujtime
- SGP_calculateSun (jtime)
- if sgp_sun.ele > const_twilightCivil then
- repeat
- jtime = jtime - 0.000694446 * 10
- SGP_calculateSun (jtime)
- until (sgp_sun.ele < const_twilightCivil)
- repeat
- jtime = jtime + 0.000694446
- SGP_calculateSun (jtime)
- until (sgp_sun.ele > const_twilightCivil)
- repeat
- jtime = jtime - 0.000694446 * 0.16
- SGP_calculateSun (jtime)
- until (sgp_sun.ele <= const_twilightCivil)
- else
- repeat
- jtime = jtime + 0.000694446 * 10
- SGP_calculateSun (jtime)
- until (sgp_sun.ele > const_twilightCivil)
- repeat
- jtime = jtime - 0.000694446
- SGP_calculateSun (jtime)
- until (sgp_sun.ele < const_twilightCivil)
- repeat
- jtime = jtime + 0.000694446 * 0.16
- SGP_calculateSun (jtime)
- until (sgp_sun.ele >= const_twilightCivil)
- end
- SGP_calculateSun (sgp_time.ujtime)
- sgp_location.day.jt = SGP_UTC_to_Local(jtime)
- sgp_location.day.year , sgp_location.day.month, sgp_location.day.day, sgp_location.day.hour, sgp_location.day.min, sgp_location.day.sec = SGP_Julian_To_Date(sgp_location.day.jt)
- end
- function SGP_calculateNightBegining()
- SGP_getCurrentTime()
- local jtime = sgp_time.ujtime
- SGP_calculateSun (jtime)
- if sgp_sun.ele < const_twilightCivil then
- repeat
- jtime = jtime - 0.000694446 * 10
- SGP_calculateSun (jtime)
- until (sgp_sun.ele > const_twilightCivil)
- repeat
- jtime = jtime + 0.000694446
- SGP_calculateSun (jtime)
- until (sgp_sun.ele < const_twilightCivil)
- repeat
- jtime = jtime - 0.000694446 * 0.16
- SGP_calculateSun (jtime)
- until (sgp_sun.ele >= const_twilightCivil)
- else
- repeat
- jtime = jtime + 0.000694446 * 10
- SGP_calculateSun (jtime)
- until (sgp_sun.ele < const_twilightCivil)
- repeat
- jtime = jtime - 0.000694446
- SGP_calculateSun (jtime)
- until (sgp_sun.ele > const_twilightCivil)
- repeat
- jtime = jtime + 0.000694446 * 0.16
- SGP_calculateSun (jtime)
- until (sgp_sun.ele <= const_twilightCivil)
- end
- SGP_calculateSun (sgp_time.ujtime)
- sgp_location.night.jt = SGP_UTC_to_Local(jtime)
- sgp_location.night.year , sgp_location.night.month, sgp_location.night.day, sgp_location.night.hour, sgp_location.night.min, sgp_location.night.sec = SGP_Julian_To_Date(sgp_location.night.jt)
- end
- -- COMIENZO DEL PROGRAMA - MAIN ()
- SF_initialize()
- -- Calculamos otras informaciones (fases lunares, amaneceres y ocasos...)
- SF_clacularOtrosDatos()
- sf_timer = timer.new()
- while true do
- -- Obtenemos el tiempo actual
- SGP_getCurrentTime()
- -- Guardamos el valor anterior del tiempo
- if sf_primer_calculo then
- sf_current_jtime_ant = sgp_time.jtime
- sf_current_jtime = sgp_time.jtime
- else
- sf_current_jtime_ant = sf_current_jtime
- sf_current_jtime = sgp_time.jtime
- end
- -- Iniciamos el timer que mide el tiempo empleado en calculos
- sf_timer:start()
- --COMIENZA CALCULO
- -- Borramos el lienzo que se sacará a pantalla
- screen.clear(sf_sky.color)
- -- Dibujamos las lineas y texto de referencia
- SF_dibuarLineasReferencia()
- -- Dibujamos las constelacioens
- SF_procesarConstelaciones(sgp_time.ujtime)
- -- Dibujamos estrellas
- SF_procesarEstrellas(sgp_time.ujtime)
- -- Dibujamos el Sol
- SF_procesarSol(sgp_time.ujtime)
- -- Dibujamos la Luna
- SF_procesarLuna(sgp_time.ujtime)
- -- Dibujamos los satélites artificiales
- SF_procesarSatelites(sgp_time.ujtime)
- if sf_r_pressed and not sf_zoom_mode then
- SF_drawLocationInfo ()
- SF_drawTimeInfo ()
- SF_drawPSPInfo ()
- end
- -- Cogemos el tiempo invertido
- sf_milis_calculos = sf_timer:stop()
- sf_timer:reset()
- -- Guardamos fotogramas por segundo
- sf_fps = 1000.0 / sf_milis_calculos
- --screen.print(0, 0, string.format ("%.2f",sf_fps) .. " fps - "..string.format ("%.1f",sgp_mag_limit).." magnitud - sat ".. cursor_satelite.." star ".. cursor_stars , sf_color_white)
- if not sf_r_pressed then
- SF_drawInfoBar(true)
- end
- -- Esperamos al refresco vertical
- screen.waitvblankstart()
- -- Pintar lienzo en pantalla
- screen.flip()
- -- Reproducir voces de aviso si hay que avisar de algo
- SND_playSoundsIfNeeded()
- -- Vemos si hay alguna tecla pulsada y actuamos en consecuencia
- SF_readInput()
- -- Si terminamos el primer calculo, establecer que ya no estamos en el primer calculo
- if sf_primer_calculo then
- -- Cambiamos a la paleta adecuada a las condiciones del cielo.
- if sgp_location.noche then
- sf_vision_nocturna = true
- SF_changePalette (sf_color_night.r,sf_color_night.g,sf_color_night.b)
- else
- sf_vision_nocturna = false
- SF_changePalette (sf_color_day.r,sf_color_day.g,sf_color_day.b)
- end
- sf_primer_calculo = false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement